Merge branch 'master' of github.com:peter-iakovlev/TelegramUI

This commit is contained in:
Ilya Laktyushin 2018-09-07 01:09:13 +03:00
commit 2e5d6896a0
3 changed files with 24 additions and 7 deletions

View File

@ -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<CombinedView>()
installedStickerPacks.set(account.postbox.combinedView(keys: [.itemCollectionIds(namespaces: [Namespaces.ItemCollection.CloudStickerPacks])]))

View File

@ -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:

View File

@ -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()))