This commit is contained in:
overtake 2019-03-19 22:20:12 +04:00
commit d9e87e686f
3 changed files with 26 additions and 8 deletions

View File

@ -1221,10 +1221,14 @@ public class Account {
public func resetStateManagement() { public func resetStateManagement() {
self.stateManager.reset() self.stateManager.reset()
self.contactSyncManager.beginSync(importableContacts: self.importableContacts.get()) self.restartContactManagement()
self.managedStickerPacksDisposable.set(manageStickerPacks(network: self.network, postbox: self.postbox).start()) self.managedStickerPacksDisposable.set(manageStickerPacks(network: self.network, postbox: self.postbox).start())
} }
public func restartContactManagement() {
self.contactSyncManager.beginSync(importableContacts: self.importableContacts.get())
}
public func peerInputActivities(peerId: PeerId) -> Signal<[(PeerId, PeerInputActivity)], NoError> { public func peerInputActivities(peerId: PeerId) -> Signal<[(PeerId, PeerInputActivity)], NoError> {
return self.peerInputActivityManager.activities(peerId: peerId) return self.peerInputActivityManager.activities(peerId: peerId)
|> map { activities in |> map { activities in

View File

@ -167,18 +167,32 @@ public func deleteContactPeerInteractively(account: Account, peerId: PeerId) ->
|> switchToLatest |> switchToLatest
} }
public func deleteAllContacts(postbox: Postbox, network: Network) -> Signal<Void, NoError> { public func deleteAllContacts(account: Account) -> Signal<Never, NoError> {
return postbox.transaction { transaction -> [Api.InputUser] in return account.postbox.transaction { transaction -> [Api.InputUser] in
return transaction.getContactPeerIds().compactMap(transaction.getPeer).compactMap({ apiInputUser($0) }).compactMap({ $0 }) return transaction.getContactPeerIds().compactMap(transaction.getPeer).compactMap({ apiInputUser($0) }).compactMap({ $0 })
} }
|> mapToSignal { users -> Signal<Void, NoError> in |> mapToSignal { users -> Signal<Never, NoError> in
return network.request(Api.functions.contacts.deleteContacts(id: users)) let deleteContacts = account.network.request(Api.functions.contacts.deleteContacts(id: users))
|> `catch` { _ -> Signal<Api.Bool, NoError> in |> `catch` { _ -> Signal<Api.Bool, NoError> in
return .single(.boolFalse) return .single(.boolFalse)
} }
let deleteImported = account.network.request(Api.functions.contacts.resetSaved())
|> `catch` { _ -> Signal<Api.Bool, NoError> in
return .single(.boolFalse)
}
return combineLatest(deleteContacts, deleteImported)
|> mapToSignal { _ -> Signal<Never, NoError> in
return account.postbox.transaction { transaction -> Void in
transaction.replaceContactPeerIds(Set())
transaction.clearDeviceContactImportInfoIdentifiers()
}
|> mapToSignal { _ -> Signal<Void, NoError> in |> mapToSignal { _ -> Signal<Void, NoError> in
account.restartContactManagement()
return .complete() return .complete()
} }
|> ignoreValues
}
} }
} }

View File

@ -11,7 +11,7 @@ public final class NotificationExceptionsList: Equatable {
public let peers: [PeerId: Peer] public let peers: [PeerId: Peer]
public let settings: [PeerId: TelegramPeerNotificationSettings] public let settings: [PeerId: TelegramPeerNotificationSettings]
init(peers: [PeerId: Peer], settings: [PeerId: TelegramPeerNotificationSettings]) { public init(peers: [PeerId: Peer], settings: [PeerId: TelegramPeerNotificationSettings]) {
self.peers = peers self.peers = peers
self.settings = settings self.settings = settings
} }