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() {
self.stateManager.reset()
self.contactSyncManager.beginSync(importableContacts: self.importableContacts.get())
self.restartContactManagement()
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> {
return self.peerInputActivityManager.activities(peerId: peerId)
|> map { activities in

View File

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

View File

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