From b83248d844d7d3fc178843f1f9cdc607004a5c68 Mon Sep 17 00:00:00 2001 From: overtake <> Date: Thu, 6 Sep 2018 22:58:58 +0100 Subject: [PATCH] no message --- TelegramUI/ArhivedStickerPacksController.swift | 7 ++++++- TelegramUI/InstalledStickerPacksController.swift | 13 +++++++++---- TelegramUI/SettingsController.swift | 11 +++++++++-- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/TelegramUI/ArhivedStickerPacksController.swift b/TelegramUI/ArhivedStickerPacksController.swift index ecc80c2344..4d4d569fc9 100644 --- a/TelegramUI/ArhivedStickerPacksController.swift +++ b/TelegramUI/ArhivedStickerPacksController.swift @@ -221,7 +221,7 @@ private func archivedStickerPacksControllerEntries(presentationData: Presentatio return entries } -public func archivedStickerPacksController(account: Account, archived: [ArchivedStickerPackItem]?) -> ViewController { +public func archivedStickerPacksController(account: Account, archived: [ArchivedStickerPackItem]?, updatedPacks: @escaping([ArchivedStickerPackItem]?)->Void) -> ViewController { let statePromise = ValuePromise(ArchivedStickerPacksControllerState(), ignoreRepeated: true) let stateValue = Atomic(value: ArchivedStickerPacksControllerState()) let updateState: ((ArchivedStickerPacksControllerState) -> ArchivedStickerPacksControllerState) -> Void = { f in @@ -241,6 +241,11 @@ public func archivedStickerPacksController(account: Account, archived: [Archived let stickerPacks = Promise<[ArchivedStickerPackItem]?>() stickerPacks.set(.single(archived) |> then(archivedStickerPacks(account: account) |> map(Optional.init))) + + actionsDisposable.add(stickerPacks.get().start(next: { packs in + updatedPacks(packs) + })) + let installedStickerPacks = Promise() installedStickerPacks.set(account.postbox.combinedView(keys: [.itemCollectionIds(namespaces: [Namespaces.ItemCollection.CloudStickerPacks])])) diff --git a/TelegramUI/InstalledStickerPacksController.swift b/TelegramUI/InstalledStickerPacksController.swift index e304bbd458..8e1d4145d3 100644 --- a/TelegramUI/InstalledStickerPacksController.swift +++ b/TelegramUI/InstalledStickerPacksController.swift @@ -378,7 +378,7 @@ public enum InstalledStickerPacksControllerMode { case masks } -public func installedStickerPacksController(account: Account, mode: InstalledStickerPacksControllerMode, archivedPacks:[ArchivedStickerPackItem]? = nil) -> ViewController { +public func installedStickerPacksController(account: Account, mode: InstalledStickerPacksControllerMode, archivedPacks:[ArchivedStickerPackItem]? = nil, updatedPacks: @escaping([ArchivedStickerPackItem]?) -> Void = { _ in}) -> ViewController { let initialState = InstalledStickerPacksControllerState().withUpdatedEditing(mode == .modal) let statePromise = ValuePromise(initialState, ignoreRepeated: true) let stateValue = Atomic(value: initialState) @@ -396,6 +396,9 @@ public func installedStickerPacksController(account: Account, mode: InstalledSti let resolveDisposable = MetaDisposable() actionsDisposable.add(resolveDisposable) + let archivedPromise = Promise<[ArchivedStickerPackItem]?>() + + var presentStickerPackController: ((StickerPackCollectionInfo) -> Void)? let arguments = InstalledStickerPacksControllerArguments(account: account, openStickerPack: { info in @@ -436,11 +439,14 @@ public func installedStickerPacksController(account: Account, mode: InstalledSti } })) }, openMasks: { - pushControllerImpl?(installedStickerPacksController(account: account, mode: .masks, archivedPacks: archivedPacks)) + pushControllerImpl?(installedStickerPacksController(account: account, mode: .masks, archivedPacks: archivedPacks, updatedPacks: { _ in})) }, openFeatured: { pushControllerImpl?(featuredStickerPacksController(account: account)) }, openArchived: { archived in - pushControllerImpl?(archivedStickerPacksController(account: account, archived: archived)) + pushControllerImpl?(archivedStickerPacksController(account: account, archived: archived, updatedPacks: { packs in + archivedPromise.set(.single(packs)) + updatedPacks(packs) + })) }, openSuggestOptions: { let presentationData = account.telegramApplicationContext.currentPresentationData.with { $0 } let controller = ActionSheetController(presentationTheme: presentationData.theme) @@ -484,7 +490,6 @@ public func installedStickerPacksController(account: Account, mode: InstalledSti stickerPacks.set(account.postbox.combinedView(keys: [.itemCollectionInfos(namespaces: [namespaceForMode(mode)])])) let featured = Promise<[FeaturedStickerPackItem]>() - let archivedPromise = Promise<[ArchivedStickerPackItem]?>() switch mode { case .general, .modal: diff --git a/TelegramUI/SettingsController.swift b/TelegramUI/SettingsController.swift index e201219378..1c62710f97 100644 --- a/TelegramUI/SettingsController.swift +++ b/TelegramUI/SettingsController.swift @@ -45,6 +45,7 @@ private struct SettingsItemArguments { let openSupport: () -> Void let openFaq: () -> Void let openEditing: () -> Void + let updateArchivedPacks: ([ArchivedStickerPackItem]?) -> Void } private enum SettingsSection: Int32 { @@ -285,7 +286,9 @@ private enum SettingsEntry: ItemListNodeEntry { }) case let .stickers(theme, image, text, value, archivedPacks): return ItemListDisclosureItem(theme: theme, icon: image, title: text, label: value, labelStyle: .badge, sectionId: ItemListSectionId(self.section), style: .blocks, action: { - arguments.pushController(installedStickerPacksController(account: arguments.account, mode: .general, archivedPacks: archivedPacks)) + arguments.pushController(installedStickerPacksController(account: arguments.account, mode: .general, archivedPacks: archivedPacks, updatedPacks: { packs in + arguments.updateArchivedPacks(packs) + })) }) case let .notificationsAndSounds(theme, image, text): return ItemListDisclosureItem(theme: theme, icon: image, title: text, label: "", sectionId: ItemListSectionId(self.section), style: .blocks, action: { @@ -426,6 +429,9 @@ public func settingsController(account: Account, accountManager: AccountManager) var changeProfilePhotoImpl: (() -> Void)? var openSavedMessagesImpl: (() -> Void)? + let archivedPacks = Promise<[ArchivedStickerPackItem]?>() + + let openFaq: () -> Void = { let presentationData = account.telegramApplicationContext.currentPresentationData.with { $0 } var faqUrl = presentationData.strings.Settings_FAQ_URL @@ -517,6 +523,8 @@ public func settingsController(account: Account, accountManager: AccountManager) pushControllerImpl?(editSettingsController(account: account, currentName: .personName(firstName: peer.firstName ?? "", lastName: peer.lastName ?? ""), currentBioText: cachedData.about ?? "", accountManager: accountManager)) } }) + }, updateArchivedPacks: { packs in + archivedPacks.set(.single(packs)) }) changeProfilePhotoImpl = { @@ -601,7 +609,6 @@ public func settingsController(account: Account, accountManager: AccountManager) let peerView = account.viewTracker.peerView(account.peerId) - let archivedPacks = Promise<[ArchivedStickerPackItem]?>() archivedPacks.set(.single(nil) |> then(archivedStickerPacks(account: account) |> map(Optional.init))) let signal = combineLatest((account.applicationContext as! TelegramApplicationContext).presentationData, statePromise.get(), peerView, account.postbox.preferencesView(keys: [PreferencesKeys.proxySettings]), combineLatest(account.viewTracker.featuredStickerPacks(), archivedPacks.get()))