mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-14 16:08:51 +00:00
Refactoring
This commit is contained in:
parent
0ab87d6bbc
commit
2efced46b3
@ -2766,7 +2766,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
private func prepareRandomGreetingSticker() {
|
||||
let context = self.context
|
||||
self.preloadedSticker.set(.single(nil)
|
||||
|> then(randomGreetingSticker(account: context.account)
|
||||
|> then(context.engine.stickers.randomGreetingSticker()
|
||||
|> map { item in
|
||||
return item?.file
|
||||
}))
|
||||
|
@ -526,11 +526,10 @@ public class ContactsController: ViewController {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
private func prepareRandomGreetingSticker() {
|
||||
let context = self.context
|
||||
self.preloadedSticker.set(.single(nil)
|
||||
|> then(randomGreetingSticker(account: context.account)
|
||||
|> then(context.engine.stickers.randomGreetingSticker()
|
||||
|> map { item in
|
||||
return item?.file
|
||||
}))
|
||||
|
@ -69,8 +69,8 @@ private func loadCountryCodes() -> [Country] {
|
||||
private var countryCodes: [Country] = loadCountryCodes()
|
||||
private var countryCodesByPrefix: [String: (Country, Country.CountryCode)] = [:]
|
||||
|
||||
public func loadServerCountryCodes(accountManager: AccountManager, network: Network, completion: @escaping () -> Void) {
|
||||
let _ = (getCountriesList(accountManager: accountManager, network: network, langCode: nil)
|
||||
public func loadServerCountryCodes(accountManager: AccountManager, engine: TelegramEngineUnauthorized, completion: @escaping () -> Void) {
|
||||
let _ = (engine.localization.getCountriesList(accountManager: accountManager, langCode: nil)
|
||||
|> deliverOnMainQueue).start(next: { countries in
|
||||
countryCodes = countries
|
||||
|
||||
@ -93,6 +93,30 @@ public func loadServerCountryCodes(accountManager: AccountManager, network: Netw
|
||||
})
|
||||
}
|
||||
|
||||
public func loadServerCountryCodes(accountManager: AccountManager, engine: TelegramEngine, completion: @escaping () -> Void) {
|
||||
let _ = (engine.localization.getCountriesList(accountManager: accountManager, langCode: nil)
|
||||
|> deliverOnMainQueue).start(next: { countries in
|
||||
countryCodes = countries
|
||||
|
||||
var countriesByPrefix: [String: (Country, Country.CountryCode)] = [:]
|
||||
for country in countries {
|
||||
for code in country.countryCodes {
|
||||
if !code.prefixes.isEmpty {
|
||||
for prefix in code.prefixes {
|
||||
countriesByPrefix["\(code.code)\(prefix)"] = (country, code)
|
||||
}
|
||||
} else {
|
||||
countriesByPrefix[code.code] = (country, code)
|
||||
}
|
||||
}
|
||||
}
|
||||
countryCodesByPrefix = countriesByPrefix
|
||||
Queue.mainQueue().async {
|
||||
completion()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private final class AuthorizationSequenceCountrySelectionNavigationContentNode: NavigationBarContentNode {
|
||||
private let theme: PresentationTheme
|
||||
private let strings: PresentationStrings
|
||||
|
@ -353,7 +353,7 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
||||
|> delay(0.15, queue: Queue.mainQueue())
|
||||
let progressDisposable = progressSignal.start()
|
||||
|
||||
let signal = stickerPacksAttachedToMedia(account: context.account, media: media)
|
||||
let signal = context.engine.stickers.stickerPacksAttachedToMedia(media: media)
|
||||
|> afterDisposed {
|
||||
Queue.mainQueue().async {
|
||||
progressDisposable.dispose()
|
||||
|
@ -1637,7 +1637,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
||||
|
||||
self.isInteractingPromise.set(true)
|
||||
|
||||
let signal = stickerPacksAttachedToMedia(account: self.context.account, media: media)
|
||||
let signal = self.context.engine.stickers.stickerPacksAttachedToMedia(media: media)
|
||||
|> afterDisposed {
|
||||
Queue.mainQueue().async {
|
||||
progressDisposable.dispose()
|
||||
|
@ -74,7 +74,7 @@ public func legacySuggestionContext(context: AccountContext, peerId: PeerId, cha
|
||||
return SSignal.complete()
|
||||
}
|
||||
return SSignal { subscriber in
|
||||
let disposable = (searchEmojiKeywords(postbox: context.account.postbox, inputLanguageCode: inputLanguageCode, query: query, completeMatch: query.count < 3)
|
||||
let disposable = (context.engine.stickers.searchEmojiKeywords(inputLanguageCode: inputLanguageCode, query: query, completeMatch: query.count < 3)
|
||||
|> map { keywords -> [TGAlphacodeEntry] in
|
||||
var result: [TGAlphacodeEntry] = []
|
||||
for keyword in keywords {
|
||||
|
@ -323,7 +323,7 @@ public func groupStickerPackSetupController(context: AccountContext, peerId: Pee
|
||||
|
||||
let initialData = Promise<InitialStickerPackData?>()
|
||||
if let currentPackInfo = currentPackInfo {
|
||||
initialData.set(cachedStickerPack(postbox: context.account.postbox, network: context.account.network, reference: .id(id: currentPackInfo.id.id, accessHash: currentPackInfo.accessHash), forceRemote: false)
|
||||
initialData.set(context.engine.stickers.cachedStickerPack(reference: .id(id: currentPackInfo.id.id, accessHash: currentPackInfo.accessHash), forceRemote: false)
|
||||
|> map { result -> InitialStickerPackData? in
|
||||
switch result {
|
||||
case .none:
|
||||
@ -363,7 +363,7 @@ public func groupStickerPackSetupController(context: AccountContext, peerId: Pee
|
||||
}
|
||||
}
|
||||
return .single((searchText, .searching))
|
||||
|> then((loadedStickerPack(postbox: context.account.postbox, network: context.account.network, reference: .name(searchText.lowercased()), forceActualized: false) |> delay(0.3, queue: Queue.concurrentDefaultQueue()))
|
||||
|> then((context.engine.stickers.loadedStickerPack(reference: .name(searchText.lowercased()), forceActualized: false) |> delay(0.3, queue: Queue.concurrentDefaultQueue()))
|
||||
|> mapToSignal { value -> Signal<(String, GroupStickerPackSearchState), NoError> in
|
||||
switch value {
|
||||
case .fetching:
|
||||
|
@ -90,7 +90,7 @@ final class ChangePhoneNumberController: ViewController, MFMailComposeViewContro
|
||||
}
|
||||
}
|
||||
|
||||
loadServerCountryCodes(accountManager: self.context.sharedContext.accountManager, network: self.context.account.network, completion: { [weak self] in
|
||||
loadServerCountryCodes(accountManager: self.context.sharedContext.accountManager, engine: self.context.engine, completion: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.controllerNode.updateCountryCode()
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ public func archivedStickerPacksController(context: AccountContext, mode: Archiv
|
||||
namespace = .masks
|
||||
}
|
||||
let stickerPacks = Promise<[ArchivedStickerPackItem]?>()
|
||||
stickerPacks.set(.single(archived) |> then(archivedStickerPacks(account: context.account, namespace: namespace) |> map(Optional.init)))
|
||||
stickerPacks.set(.single(archived) |> then(context.engine.stickers.archivedStickerPacks(namespace: namespace) |> map(Optional.init)))
|
||||
|
||||
actionsDisposable.add(stickerPacks.get().start(next: { packs in
|
||||
updatedPacks(packs)
|
||||
@ -302,17 +302,16 @@ public func archivedStickerPacksController(context: AccountContext, mode: Archiv
|
||||
if !add {
|
||||
return
|
||||
}
|
||||
let _ = (loadedStickerPack(postbox: context.account.postbox, network: context.account.network, reference: .id(id: info.id.id, accessHash: info.accessHash), forceActualized: false)
|
||||
let _ = (context.engine.stickers.loadedStickerPack(reference: .id(id: info.id.id, accessHash: info.accessHash), forceActualized: false)
|
||||
|> mapToSignal { result -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> in
|
||||
switch result {
|
||||
case let .result(info, items, installed):
|
||||
if installed {
|
||||
return .complete()
|
||||
} else {
|
||||
return addStickerPackInteractively(postbox: context.account.postbox, info: info, items: items)
|
||||
return context.engine.stickers.addStickerPackInteractively(info: info, items: items)
|
||||
|> ignoreValues
|
||||
|> mapToSignal { _ -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> in
|
||||
return .complete()
|
||||
}
|
||||
|> then(.single((info, items)))
|
||||
}
|
||||
@ -336,7 +335,7 @@ public func archivedStickerPacksController(context: AccountContext, mode: Archiv
|
||||
}
|
||||
}
|
||||
|
||||
presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, account: context.account), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, context: context), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
return true
|
||||
}), nil)
|
||||
|
||||
@ -390,7 +389,7 @@ public func archivedStickerPacksController(context: AccountContext, mode: Archiv
|
||||
|
||||
return .complete()
|
||||
}
|
||||
removePackDisposables.set((removeArchivedStickerPack(account: context.account, info: info) |> then(applyPacks) |> deliverOnMainQueue).start(completed: {
|
||||
removePackDisposables.set((context.engine.stickers.removeArchivedStickerPack(info: info) |> then(applyPacks) |> deliverOnMainQueue).start(completed: {
|
||||
updateState { state in
|
||||
var removingPackIds = state.removingPackIds
|
||||
removingPackIds.remove(info.id)
|
||||
|
@ -180,14 +180,14 @@ public func featuredStickerPacksController(context: AccountContext) -> ViewContr
|
||||
let arguments = FeaturedStickerPacksControllerArguments(account: context.account, openStickerPack: { info in
|
||||
presentStickerPackController?(info)
|
||||
}, addPack: { info in
|
||||
let _ = (loadedStickerPack(postbox: context.account.postbox, network: context.account.network, reference: .id(id: info.id.id, accessHash: info.accessHash), forceActualized: false)
|
||||
let _ = (context.engine.stickers.loadedStickerPack(reference: .id(id: info.id.id, accessHash: info.accessHash), forceActualized: false)
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
switch result {
|
||||
case let .result(info, items, installed):
|
||||
if installed {
|
||||
return .complete()
|
||||
} else {
|
||||
return addStickerPackInteractively(postbox: context.account.postbox, info: info, items: items)
|
||||
return context.engine.stickers.addStickerPackInteractively(info: info, items: items)
|
||||
}
|
||||
case .fetching:
|
||||
break
|
||||
@ -254,7 +254,7 @@ public func featuredStickerPacksController(context: AccountContext) -> ViewContr
|
||||
if !unreadIds.isEmpty {
|
||||
alreadyReadIds.formUnion(Set(unreadIds))
|
||||
|
||||
let _ = markFeaturedStickerPacksAsSeenInteractively(postbox: context.account.postbox, ids: unreadIds).start()
|
||||
let _ = context.engine.stickers.markFeaturedStickerPacksAsSeenInteractively(ids: unreadIds).start()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -532,7 +532,7 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
||||
controller?.dismissAnimated()
|
||||
}
|
||||
let removeAction: (RemoveStickerPackOption) -> Void = { action in
|
||||
let _ = (removeStickerPackInteractively(postbox: context.account.postbox, id: archivedItem.info.id, option: action)
|
||||
let _ = (context.engine.stickers.removeStickerPackInteractively(id: archivedItem.info.id, option: action)
|
||||
|> deliverOnMainQueue).start(next: { indexAndItems in
|
||||
guard let (positionInList, items) = indexAndItems else {
|
||||
return
|
||||
@ -548,9 +548,9 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
||||
}
|
||||
}
|
||||
|
||||
navigationControllerImpl?()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: action == .archive ? presentationData.strings.StickerPackActionInfo_ArchivedTitle : presentationData.strings.StickerPackActionInfo_RemovedTitle, text: presentationData.strings.StickerPackActionInfo_RemovedText(archivedItem.info.title).0, undo: true, info: archivedItem.info, topItem: archivedItem.topItems.first, account: context.account), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { action in
|
||||
navigationControllerImpl?()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: action == .archive ? presentationData.strings.StickerPackActionInfo_ArchivedTitle : presentationData.strings.StickerPackActionInfo_RemovedTitle, text: presentationData.strings.StickerPackActionInfo_RemovedText(archivedItem.info.title).0, undo: true, info: archivedItem.info, topItem: archivedItem.topItems.first, context: context), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { action in
|
||||
if case .undo = action {
|
||||
let _ = addStickerPackInteractively(postbox: context.account.postbox, info: archivedItem.info, items: items, positionInList: positionInList).start()
|
||||
let _ = context.engine.stickers.addStickerPackInteractively(info: archivedItem.info, items: items, positionInList: positionInList).start()
|
||||
}
|
||||
return true
|
||||
}))
|
||||
@ -655,10 +655,10 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
||||
switch mode {
|
||||
case .general, .modal:
|
||||
featured.set(context.account.viewTracker.featuredStickerPacks())
|
||||
archivedPromise.set(.single(archivedPacks) |> then(archivedStickerPacks(account: context.account) |> map(Optional.init)))
|
||||
archivedPromise.set(.single(archivedPacks) |> then(context.engine.stickers.archivedStickerPacks() |> map(Optional.init)))
|
||||
case .masks:
|
||||
featured.set(.single([]))
|
||||
archivedPromise.set(.single(nil) |> then(archivedStickerPacks(account: context.account, namespace: .masks) |> map(Optional.init)))
|
||||
archivedPromise.set(.single(nil) |> then(context.engine.stickers.archivedStickerPacks(namespace: .masks) |> map(Optional.init)))
|
||||
}
|
||||
|
||||
var previousPackCount: Int?
|
||||
@ -717,7 +717,7 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
||||
}
|
||||
}
|
||||
|
||||
let _ = removeStickerPacksInteractively(postbox: context.account.postbox, ids: packIds, option: .delete).start()
|
||||
let _ = context.engine.stickers.removeStickerPacksInteractively(ids: packIds, option: .delete).start()
|
||||
}))
|
||||
actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [
|
||||
ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
||||
@ -742,7 +742,7 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
||||
}
|
||||
}
|
||||
|
||||
let _ = removeStickerPacksInteractively(postbox: context.account.postbox, ids: packIds, option: .archive).start()
|
||||
let _ = context.engine.stickers.removeStickerPacksInteractively(ids: packIds, option: .archive).start()
|
||||
}))
|
||||
actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [
|
||||
ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
||||
@ -954,13 +954,13 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
||||
}
|
||||
switch action {
|
||||
case .add:
|
||||
navigationControllerImpl?()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, account: context.account), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
navigationControllerImpl?()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, context: context), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
return true
|
||||
}))
|
||||
case let .remove(positionInList):
|
||||
navigationControllerImpl?()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_RemovedTitle, text: presentationData.strings.StickerPackActionInfo_RemovedText(info.title).0, undo: true, info: info, topItem: items.first, account: context.account), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { action in
|
||||
navigationControllerImpl?()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_RemovedTitle, text: presentationData.strings.StickerPackActionInfo_RemovedText(info.title).0, undo: true, info: info, topItem: items.first, context: context), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { action in
|
||||
if case .undo = action {
|
||||
let _ = addStickerPackInteractively(postbox: context.account.postbox, info: info, items: items, positionInList: positionInList).start()
|
||||
let _ = context.engine.stickers.addStickerPackInteractively(info: info, items: items, positionInList: positionInList).start()
|
||||
}
|
||||
return true
|
||||
}))
|
||||
|
@ -82,7 +82,7 @@ public final class StickerPackPreviewController: ViewController, StandalonePrese
|
||||
self.acceptsFocusWhenInOverlay = true
|
||||
self.statusBar.statusBarStyle = .Ignore
|
||||
|
||||
self.stickerPackContents.set(loadedStickerPack(postbox: context.account.postbox, network: context.account.network, reference: stickerPack, forceActualized: true))
|
||||
self.stickerPackContents.set(context.engine.stickers.loadedStickerPack(reference: stickerPack, forceActualized: true))
|
||||
|
||||
self.presentationDataDisposable = (context.sharedContext.presentationData
|
||||
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
|
||||
|
@ -521,7 +521,7 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
||||
switch stickerPack {
|
||||
case let .result(info, items, installed):
|
||||
if installed {
|
||||
let _ = (removeStickerPackInteractively(postbox: self.context.account.postbox, id: info.id, option: .delete)
|
||||
let _ = (self.context.engine.stickers.removeStickerPackInteractively(id: info.id, option: .delete)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] indexAndItems in
|
||||
guard let strongSelf = self, let (positionInList, _) = indexAndItems else {
|
||||
return
|
||||
@ -532,7 +532,7 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
|
||||
self.updateStickerPack(.result(info: info, items: items, installed: false), stickerSettings: stickerSettings)
|
||||
}
|
||||
} else {
|
||||
let _ = addStickerPackInteractively(postbox: self.context.account.postbox, info: info, items: items).start()
|
||||
let _ = self.context.engine.stickers.addStickerPackInteractively(info: info, items: items).start()
|
||||
if !dismissOnAction {
|
||||
self.updateStickerPack(.result(info: info, items: items, installed: true), stickerSettings: stickerSettings)
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ private final class StickerPackContainer: ASDisplayNode {
|
||||
return updatedOffset
|
||||
}
|
||||
|
||||
self.itemsDisposable = (loadedStickerPack(postbox: context.account.postbox, network: context.account.network, reference: stickerPack, forceActualized: false)
|
||||
self.itemsDisposable = (context.engine.stickers.loadedStickerPack(reference: stickerPack, forceActualized: false)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] contents in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
@ -340,9 +340,9 @@ private final class StickerPackContainer: ASDisplayNode {
|
||||
return
|
||||
}
|
||||
if installed {
|
||||
let _ = removeStickerPackInteractively(postbox: strongSelf.context.account.postbox, id: info.id, option: .delete).start()
|
||||
let _ = strongSelf.context.engine.stickers.removeStickerPackInteractively(id: info.id, option: .delete).start()
|
||||
} else {
|
||||
let _ = addStickerPackInteractively(postbox: strongSelf.context.account.postbox, info: info, items: items).start()
|
||||
let _ = strongSelf.context.engine.stickers.addStickerPackInteractively(info: info, items: items).start()
|
||||
}
|
||||
|
||||
switch strongSelf.decideNextAction(strongSelf, installed ? .remove : .add) {
|
||||
|
@ -31,7 +31,7 @@ public func peerSpecificStickerPack(postbox: Postbox, network: Network, peerId:
|
||||
return signal
|
||||
|> mapToSignal { info, canInstall -> Signal<PeerSpecificStickerPackData, NoError> in
|
||||
if let info = info.info {
|
||||
return cachedStickerPack(postbox: postbox, network: network, reference: .id(id: info.id.id, accessHash: info.accessHash), forceRemote: false)
|
||||
return _internal_cachedStickerPack(postbox: postbox, network: network, reference: .id(id: info.id.id, accessHash: info.accessHash), forceRemote: false)
|
||||
|> map { result -> PeerSpecificStickerPackData in
|
||||
if case let .result(info, items, _) = result {
|
||||
return PeerSpecificStickerPackData(packInfo: (info, items), canSetup: canInstall)
|
||||
|
@ -5,7 +5,7 @@ import TelegramApi
|
||||
import MtProtoKit
|
||||
|
||||
func managedAnimatedEmojiUpdates(postbox: Postbox, network: Network) -> Signal<Void, NoError> {
|
||||
let poll = loadedStickerPack(postbox: postbox, network: network, reference: .animatedEmoji, forceActualized: true)
|
||||
let poll = _internal_loadedStickerPack(postbox: postbox, network: network, reference: .animatedEmoji, forceActualized: true)
|
||||
|> mapToSignal { _ -> Signal<Void, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public final class CountriesList: PreferencesEntry, Equatable {
|
||||
}
|
||||
|
||||
|
||||
public func getCountriesList(accountManager: AccountManager, network: Network, langCode: String?, forceUpdate: Bool = false) -> Signal<[Country], NoError> {
|
||||
func _internal_getCountriesList(accountManager: AccountManager, network: Network, langCode: String?, forceUpdate: Bool = false) -> Signal<[Country], NoError> {
|
||||
let fetch: ([Country]?, Int32?) -> Signal<[Country], NoError> = { current, hash in
|
||||
return network.request(Api.functions.help.getCountriesList(langCode: langCode ?? "", hash: hash ?? 0))
|
||||
|> retryRequest
|
@ -0,0 +1,30 @@
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
|
||||
public extension TelegramEngine {
|
||||
final class Localization {
|
||||
private let account: Account
|
||||
|
||||
init(account: Account) {
|
||||
self.account = account
|
||||
}
|
||||
|
||||
public func getCountriesList(accountManager: AccountManager, langCode: String?, forceUpdate: Bool = false) -> Signal<[Country], NoError> {
|
||||
return _internal_getCountriesList(accountManager: accountManager, network: self.account.network, langCode: langCode, forceUpdate: forceUpdate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension TelegramEngineUnauthorized {
|
||||
final class Localization {
|
||||
private let account: UnauthorizedAccount
|
||||
|
||||
init(account: UnauthorizedAccount) {
|
||||
self.account = account
|
||||
}
|
||||
|
||||
public func getCountriesList(accountManager: AccountManager, langCode: String?, forceUpdate: Bool = false) -> Signal<[Country], NoError> {
|
||||
return _internal_getCountriesList(accountManager: accountManager, network: self.account.network, langCode: langCode, forceUpdate: forceUpdate)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
import SwiftSignalKit
|
||||
|
||||
public extension TelegramEngine {
|
||||
final class PeerManagement {
|
||||
private let account: Account
|
||||
|
||||
init(account: Account) {
|
||||
self.account = account
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ public final class ArchivedStickerPackItem {
|
||||
}
|
||||
}
|
||||
|
||||
public func archivedStickerPacks(account: Account, namespace: ArchivedStickerPacksNamespace = .stickers) -> Signal<[ArchivedStickerPackItem], NoError> {
|
||||
func _internal_archivedStickerPacks(account: Account, namespace: ArchivedStickerPacksNamespace = .stickers) -> Signal<[ArchivedStickerPackItem], NoError> {
|
||||
var flags: Int32 = 0
|
||||
if case .masks = namespace {
|
||||
flags |= 1 << 0
|
||||
@ -50,7 +50,7 @@ public func archivedStickerPacks(account: Account, namespace: ArchivedStickerPac
|
||||
}
|
||||
}
|
||||
|
||||
public func removeArchivedStickerPack(account: Account, info: StickerPackCollectionInfo) -> Signal<Void, NoError> {
|
||||
func _internal_removeArchivedStickerPack(account: Account, info: StickerPackCollectionInfo) -> Signal<Void, NoError> {
|
||||
return account.network.request(Api.functions.messages.uninstallStickerSet(stickerset: Api.InputStickerSet.inputStickerSetID(id: info.id.id, accessHash: info.accessHash)))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .single(.boolFalse)
|
@ -36,7 +36,7 @@ func cacheStickerPack(transaction: Transaction, info: StickerPackCollectionInfo,
|
||||
}
|
||||
}
|
||||
|
||||
public func cachedStickerPack(postbox: Postbox, network: Network, reference: StickerPackReference, forceRemote: Bool) -> Signal<CachedStickerPackResult, NoError> {
|
||||
func _internal_cachedStickerPack(postbox: Postbox, network: Network, reference: StickerPackReference, forceRemote: Bool) -> Signal<CachedStickerPackResult, NoError> {
|
||||
return postbox.transaction { transaction -> CachedStickerPackResult? in
|
||||
if let (info, items, local) = cachedStickerPack(transaction: transaction, reference: reference) {
|
||||
if local {
|
@ -11,7 +11,7 @@ private enum SearchEmojiKeywordsIntermediateResult {
|
||||
case completed([EmojiKeywordItem])
|
||||
}
|
||||
|
||||
public func searchEmojiKeywords(postbox: Postbox, inputLanguageCode: String, query: String, completeMatch: Bool) -> Signal<[EmojiKeywordItem], NoError> {
|
||||
func _internal_searchEmojiKeywords(postbox: Postbox, inputLanguageCode: String, query: String, completeMatch: Bool) -> Signal<[EmojiKeywordItem], NoError> {
|
||||
guard !query.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
||||
return .single([])
|
||||
}
|
@ -95,8 +95,8 @@ func updatedRemoteStickerPack(postbox: Postbox, network: Network, reference: Sti
|
||||
}
|
||||
}
|
||||
|
||||
public func loadedStickerPack(postbox: Postbox, network: Network, reference: StickerPackReference, forceActualized: Bool) -> Signal<LoadedStickerPack, NoError> {
|
||||
return cachedStickerPack(postbox: postbox, network: network, reference: reference, forceRemote: forceActualized)
|
||||
func _internal_loadedStickerPack(postbox: Postbox, network: Network, reference: StickerPackReference, forceActualized: Bool) -> Signal<LoadedStickerPack, NoError> {
|
||||
return _internal_cachedStickerPack(postbox: postbox, network: network, reference: reference, forceRemote: forceActualized)
|
||||
|> map { result -> LoadedStickerPack in
|
||||
switch result {
|
||||
case .none:
|
@ -58,7 +58,7 @@ public struct SearchStickersScope: OptionSet {
|
||||
public static let remote = SearchStickersScope(rawValue: 1 << 1)
|
||||
}
|
||||
|
||||
public func randomGreetingSticker(account: Account) -> Signal<FoundStickerItem?, NoError> {
|
||||
func _internal_randomGreetingSticker(account: Account) -> Signal<FoundStickerItem?, NoError> {
|
||||
return account.postbox.transaction { transaction -> FoundStickerItem? in
|
||||
var stickerItems: [FoundStickerItem] = []
|
||||
for entry in transaction.getOrderedListItems(collectionId: Namespaces.OrderedItemList.CloudGreetingStickers) {
|
||||
@ -70,7 +70,7 @@ public func randomGreetingSticker(account: Account) -> Signal<FoundStickerItem?,
|
||||
}
|
||||
}
|
||||
|
||||
public func searchStickers(account: Account, query: String, scope: SearchStickersScope = [.installed, .remote]) -> Signal<[FoundStickerItem], NoError> {
|
||||
func _internal_searchStickers(account: Account, query: String, scope: SearchStickersScope = [.installed, .remote]) -> Signal<[FoundStickerItem], NoError> {
|
||||
if scope.isEmpty {
|
||||
return .single([])
|
||||
}
|
||||
@ -265,7 +265,7 @@ public struct FoundStickerSets {
|
||||
}
|
||||
}
|
||||
|
||||
public func searchStickerSetsRemotely(network: Network, query: String) -> Signal<FoundStickerSets, NoError> {
|
||||
func _internal_searchStickerSetsRemotely(network: Network, query: String) -> Signal<FoundStickerSets, NoError> {
|
||||
return network.request(Api.functions.messages.searchStickerSets(flags: 0, q: query, hash: 0))
|
||||
|> mapError {_ in}
|
||||
|> mapToSignal { value in
|
||||
@ -291,7 +291,7 @@ public func searchStickerSetsRemotely(network: Network, query: String) -> Signal
|
||||
}
|
||||
}
|
||||
|
||||
public func searchStickerSets(postbox: Postbox, query: String) -> Signal<FoundStickerSets, NoError> {
|
||||
func _internal_searchStickerSets(postbox: Postbox, query: String) -> Signal<FoundStickerSets, NoError> {
|
||||
return postbox.transaction { transaction -> Signal<FoundStickerSets, NoError> in
|
||||
let infos = transaction.getItemCollectionsInfos(namespace: Namespaces.ItemCollection.CloudStickerPacks)
|
||||
|
||||
@ -324,7 +324,7 @@ public func searchStickerSets(postbox: Postbox, query: String) -> Signal<FoundSt
|
||||
} |> switchToLatest
|
||||
}
|
||||
|
||||
public func searchGifs(account: Account, query: String, nextOffset: String = "") -> Signal<ChatContextResultCollection?, NoError> {
|
||||
func _internal_searchGifs(account: Account, query: String, nextOffset: String = "") -> Signal<ChatContextResultCollection?, NoError> {
|
||||
return account.postbox.transaction { transaction -> String in
|
||||
let configuration = currentSearchBotsConfiguration(transaction: transaction)
|
||||
return configuration.gifBotUsername ?? "gif"
|
@ -58,7 +58,7 @@ extension StickerPackCollectionInfo {
|
||||
}
|
||||
}
|
||||
|
||||
public func stickerPacksAttachedToMedia(account: Account, media: AnyMediaReference) -> Signal<[StickerPackReference], NoError> {
|
||||
func _internal_stickerPacksAttachedToMedia(account: Account, media: AnyMediaReference) -> Signal<[StickerPackReference], NoError> {
|
||||
let inputMedia: Api.InputStickeredMedia
|
||||
let resourceReference: MediaResourceReference
|
||||
if let imageReference = media.concrete(TelegramMediaImage.self), let reference = imageReference.media.reference, case let .cloud(imageId, accessHash, fileReference) = reference, let representation = largestImageRepresentation(imageReference.media.representations) {
|
@ -4,7 +4,7 @@ import SwiftSignalKit
|
||||
|
||||
import SyncCore
|
||||
|
||||
public func addStickerPackInteractively(postbox: Postbox, info: StickerPackCollectionInfo, items: [ItemCollectionItem], positionInList: Int? = nil) -> Signal<Void, NoError> {
|
||||
func _internal_addStickerPackInteractively(postbox: Postbox, info: StickerPackCollectionInfo, items: [ItemCollectionItem], positionInList: Int? = nil) -> Signal<Void, NoError> {
|
||||
return postbox.transaction { transaction -> Void in
|
||||
let namespace: SynchronizeInstalledStickerPacksOperationNamespace?
|
||||
switch info.id.namespace {
|
||||
@ -44,11 +44,11 @@ public enum RemoveStickerPackOption {
|
||||
case archive
|
||||
}
|
||||
|
||||
public func removeStickerPackInteractively(postbox: Postbox, id: ItemCollectionId, option: RemoveStickerPackOption) -> Signal<(Int, [ItemCollectionItem])?, NoError> {
|
||||
return removeStickerPacksInteractively(postbox: postbox, ids: [id], option: option)
|
||||
func _internal_removeStickerPackInteractively(postbox: Postbox, id: ItemCollectionId, option: RemoveStickerPackOption) -> Signal<(Int, [ItemCollectionItem])?, NoError> {
|
||||
return _internal_removeStickerPacksInteractively(postbox: postbox, ids: [id], option: option)
|
||||
}
|
||||
|
||||
public func removeStickerPacksInteractively(postbox: Postbox, ids: [ItemCollectionId], option: RemoveStickerPackOption) -> Signal<(Int, [ItemCollectionItem])?, NoError> {
|
||||
func _internal_removeStickerPacksInteractively(postbox: Postbox, ids: [ItemCollectionId], option: RemoveStickerPackOption) -> Signal<(Int, [ItemCollectionItem])?, NoError> {
|
||||
return postbox.transaction { transaction -> (Int, [ItemCollectionItem])? in
|
||||
var commonNamespace: SynchronizeInstalledStickerPacksOperationNamespace?
|
||||
for id in ids {
|
||||
@ -91,7 +91,7 @@ public func removeStickerPacksInteractively(postbox: Postbox, ids: [ItemCollecti
|
||||
}
|
||||
}
|
||||
|
||||
public func markFeaturedStickerPacksAsSeenInteractively(postbox: Postbox, ids: [ItemCollectionId]) -> Signal<Void, NoError> {
|
||||
func _internal_markFeaturedStickerPacksAsSeenInteractively(postbox: Postbox, ids: [ItemCollectionId]) -> Signal<Void, NoError> {
|
||||
return postbox.transaction { transaction -> Void in
|
||||
let idsSet = Set(ids)
|
||||
var items = transaction.getOrderedListItems(collectionId: Namespaces.OrderedItemList.CloudFeaturedStickerPacks)
|
@ -0,0 +1,73 @@
|
||||
import SwiftSignalKit
|
||||
import SyncCore
|
||||
import Postbox
|
||||
|
||||
public extension TelegramEngine {
|
||||
final class Stickers {
|
||||
private let account: Account
|
||||
|
||||
init(account: Account) {
|
||||
self.account = account
|
||||
}
|
||||
|
||||
public func archivedStickerPacks(namespace: ArchivedStickerPacksNamespace = .stickers) -> Signal<[ArchivedStickerPackItem], NoError> {
|
||||
return _internal_archivedStickerPacks(account: account, namespace: namespace)
|
||||
}
|
||||
|
||||
public func removeArchivedStickerPack(info: StickerPackCollectionInfo) -> Signal<Void, NoError> {
|
||||
return _internal_removeArchivedStickerPack(account: self.account, info: info)
|
||||
}
|
||||
|
||||
public func cachedStickerPack(reference: StickerPackReference, forceRemote: Bool) -> Signal<CachedStickerPackResult, NoError> {
|
||||
return _internal_cachedStickerPack(postbox: self.account.postbox, network: self.account.network, reference: reference, forceRemote: forceRemote)
|
||||
}
|
||||
|
||||
public func loadedStickerPack(reference: StickerPackReference, forceActualized: Bool) -> Signal<LoadedStickerPack, NoError> {
|
||||
return _internal_loadedStickerPack(postbox: self.account.postbox, network: self.account.network, reference: reference, forceActualized: forceActualized)
|
||||
}
|
||||
|
||||
public func randomGreetingSticker() -> Signal<FoundStickerItem?, NoError> {
|
||||
return _internal_randomGreetingSticker(account: self.account)
|
||||
}
|
||||
|
||||
public func searchStickers(query: String, scope: SearchStickersScope = [.installed, .remote]) -> Signal<[FoundStickerItem], NoError> {
|
||||
return _internal_searchStickers(account: self.account, query: query, scope: scope)
|
||||
}
|
||||
|
||||
public func searchStickerSetsRemotely(query: String) -> Signal<FoundStickerSets, NoError> {
|
||||
return _internal_searchStickerSetsRemotely(network: self.account.network, query: query)
|
||||
}
|
||||
|
||||
public func searchStickerSets(query: String) -> Signal<FoundStickerSets, NoError> {
|
||||
return _internal_searchStickerSets(postbox: self.account.postbox, query: query)
|
||||
}
|
||||
|
||||
public func searchGifs(query: String, nextOffset: String = "") -> Signal<ChatContextResultCollection?, NoError> {
|
||||
return _internal_searchGifs(account: self.account, query: query, nextOffset: nextOffset)
|
||||
}
|
||||
|
||||
public func addStickerPackInteractively(info: StickerPackCollectionInfo, items: [ItemCollectionItem], positionInList: Int? = nil) -> Signal<Void, NoError> {
|
||||
return _internal_addStickerPackInteractively(postbox: self.account.postbox, info: info, items: items, positionInList: positionInList)
|
||||
}
|
||||
|
||||
public func removeStickerPackInteractively(id: ItemCollectionId, option: RemoveStickerPackOption) -> Signal<(Int, [ItemCollectionItem])?, NoError> {
|
||||
return _internal_removeStickerPackInteractively(postbox: self.account.postbox, id: id, option: option)
|
||||
}
|
||||
|
||||
public func removeStickerPacksInteractively(ids: [ItemCollectionId], option: RemoveStickerPackOption) -> Signal<(Int, [ItemCollectionItem])?, NoError> {
|
||||
return _internal_removeStickerPacksInteractively(postbox: self.account.postbox, ids: ids, option: option)
|
||||
}
|
||||
|
||||
public func markFeaturedStickerPacksAsSeenInteractively(ids: [ItemCollectionId]) -> Signal<Void, NoError> {
|
||||
return _internal_markFeaturedStickerPacksAsSeenInteractively(postbox: self.account.postbox, ids: ids)
|
||||
}
|
||||
|
||||
public func searchEmojiKeywords(inputLanguageCode: String, query: String, completeMatch: Bool) -> Signal<[EmojiKeywordItem], NoError> {
|
||||
return _internal_searchEmojiKeywords(postbox: self.account.postbox, inputLanguageCode: inputLanguageCode, query: query, completeMatch: completeMatch)
|
||||
}
|
||||
|
||||
public func stickerPacksAttachedToMedia(media: AnyMediaReference) -> Signal<[StickerPackReference], NoError> {
|
||||
return _internal_stickerPacksAttachedToMedia(account: self.account, media: media)
|
||||
}
|
||||
}
|
||||
}
|
@ -31,6 +31,18 @@ public final class TelegramEngine {
|
||||
public lazy var accountData: AccountData = {
|
||||
return AccountData(account: self.account)
|
||||
}()
|
||||
|
||||
public lazy var stickers: Stickers = {
|
||||
return Stickers(account: self.account)
|
||||
}()
|
||||
|
||||
public lazy var peerManagement: PeerManagement = {
|
||||
return PeerManagement(account: self.account)
|
||||
}()
|
||||
|
||||
public lazy var localization: Localization = {
|
||||
return Localization(account: self.account)
|
||||
}()
|
||||
}
|
||||
|
||||
public final class TelegramEngineUnauthorized {
|
||||
@ -43,4 +55,8 @@ public final class TelegramEngineUnauthorized {
|
||||
public lazy var auth: Auth = {
|
||||
return Auth(account: self.account)
|
||||
}()
|
||||
|
||||
public lazy var localization: Localization = {
|
||||
return Localization(account: self.account)
|
||||
}()
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ final class AuthorizationSequencePhoneEntryController: ViewController {
|
||||
self?.nextPressed()
|
||||
}
|
||||
|
||||
loadServerCountryCodes(accountManager: sharedContext.accountManager, network: account.network, completion: { [weak self] in
|
||||
loadServerCountryCodes(accountManager: sharedContext.accountManager, engine: TelegramEngineUnauthorized(account: self.account), completion: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.controllerNode.updateCountryCode()
|
||||
}
|
||||
|
@ -829,7 +829,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
break
|
||||
}
|
||||
}
|
||||
let _ = combineLatest(queue: .mainQueue(), contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState: strongSelf.presentationInterfaceState, context: strongSelf.context, messages: updatedMessages, controllerInteraction: strongSelf.controllerInteraction, selectAll: selectAll, interfaceInteraction: strongSelf.interfaceInteraction), loadedStickerPack(postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network, reference: .animatedEmoji, forceActualized: false), ApplicationSpecificNotice.getChatTextSelectionTips(accountManager: strongSelf.context.sharedContext.accountManager)
|
||||
let _ = combineLatest(queue: .mainQueue(), contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState: strongSelf.presentationInterfaceState, context: strongSelf.context, messages: updatedMessages, controllerInteraction: strongSelf.controllerInteraction, selectAll: selectAll, interfaceInteraction: strongSelf.interfaceInteraction), strongSelf.context.engine.stickers.loadedStickerPack(reference: .animatedEmoji, forceActualized: false), ApplicationSpecificNotice.getChatTextSelectionTips(accountManager: strongSelf.context.sharedContext.accountManager)
|
||||
).start(next: { actions, animatedEmojiStickers, chatTextSelectionTips in
|
||||
guard let strongSelf = self, !actions.isEmpty else {
|
||||
return
|
||||
@ -6144,7 +6144,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|> switchToLatest
|
||||
|> deliverOnMainQueue).start(next: { [weak self] added in
|
||||
if let strongSelf = self {
|
||||
strongSelf.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .sticker(account: strongSelf.context.account, file: stickerFile, text: added ? strongSelf.presentationData.strings.Conversation_StickerAddedToFavorites : strongSelf.presentationData.strings.Conversation_StickerRemovedFromFavorites), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||
strongSelf.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .sticker(context: strongSelf.context, file: stickerFile, text: added ? strongSelf.presentationData.strings.Conversation_StickerAddedToFavorites : strongSelf.presentationData.strings.Conversation_StickerRemovedFromFavorites), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -9436,7 +9436,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
}
|
||||
if let value = value {
|
||||
self.present(UndoOverlayController(presentationData: self.presentationData, content: .dice(dice: dice, account: self.context.account, text: value, action: canSendMessagesToChat(self.presentationInterfaceState) ? self.presentationData.strings.Conversation_SendDice : nil), elevatedLayout: false, action: { [weak self] action in
|
||||
self.present(UndoOverlayController(presentationData: self.presentationData, content: .dice(dice: dice, context: self.context, text: value, action: canSendMessagesToChat(self.presentationInterfaceState) ? self.presentationData.strings.Conversation_SendDice : nil), elevatedLayout: false, action: { [weak self] action in
|
||||
if let strongSelf = self, canSendMessagesToChat(strongSelf.presentationInterfaceState), action == .undo {
|
||||
strongSelf.sendMessages([.message(text: "", attributes: [], mediaReference: AnyMediaReference.standalone(media: TelegramMediaDice(emoji: dice.emoji)), replyToMessageId: nil, localGroupingKey: nil, correlationId: nil)])
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
private func updateIsEmpty(_ emptyType: ChatHistoryNodeLoadState.EmptyType?, animated: Bool) {
|
||||
self.emptyType = emptyType
|
||||
if let emptyType = emptyType, self.emptyNode == nil {
|
||||
let emptyNode = ChatEmptyNode(account: self.context.account, interaction: self.interfaceInteraction)
|
||||
let emptyNode = ChatEmptyNode(context: self.context, interaction: self.interfaceInteraction)
|
||||
if let (size, insets) = self.validEmptyNodeLayout {
|
||||
emptyNode.updateLayout(interfaceState: self.chatPresentationInterfaceState, emptyType: emptyType, size: size, insets: insets, transition: .immediate)
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import TelegramPresentationData
|
||||
import AppBundle
|
||||
import LocalizedPeerData
|
||||
import TelegramStringFormatting
|
||||
import AccountContext
|
||||
|
||||
private protocol ChatEmptyNodeContent {
|
||||
func updateLayout(interfaceState: ChatPresentationInterfaceState, size: CGSize, transition: ContainedViewLayoutTransition) -> CGSize
|
||||
@ -67,7 +68,7 @@ private final class ChatEmptyNodeRegularChatContent: ASDisplayNode, ChatEmptyNod
|
||||
}
|
||||
|
||||
private final class ChatEmptyNodeGreetingChatContent: ASDisplayNode, ChatEmptyNodeContent, UIGestureRecognizerDelegate {
|
||||
private let account: Account
|
||||
private let context: AccountContext
|
||||
private let interaction: ChatPanelInterfaceInteraction?
|
||||
|
||||
private let titleNode: ImmediateTextNode
|
||||
@ -92,8 +93,8 @@ private final class ChatEmptyNodeGreetingChatContent: ASDisplayNode, ChatEmptyNo
|
||||
}
|
||||
}
|
||||
|
||||
init(account: Account, interaction: ChatPanelInterfaceInteraction?) {
|
||||
self.account = account
|
||||
init(context: AccountContext, interaction: ChatPanelInterfaceInteraction?) {
|
||||
self.context = context
|
||||
self.interaction = interaction
|
||||
|
||||
self.titleNode = ImmediateTextNode()
|
||||
@ -162,7 +163,7 @@ private final class ChatEmptyNodeGreetingChatContent: ASDisplayNode, ChatEmptyNo
|
||||
if let preloadedSticker = interfaceState.greetingData?.sticker {
|
||||
sticker = .single(preloadedSticker)
|
||||
} else {
|
||||
sticker = randomGreetingSticker(account: self.account)
|
||||
sticker = self.context.engine.stickers.randomGreetingSticker()
|
||||
|> map { item -> TelegramMediaFile? in
|
||||
return item?.file
|
||||
}
|
||||
@ -195,7 +196,7 @@ private final class ChatEmptyNodeGreetingChatContent: ASDisplayNode, ChatEmptyNo
|
||||
let index = ItemCollectionItemIndex(index: 0, id: 0)
|
||||
let collectionId = ItemCollectionId(namespace: 0, id: 0)
|
||||
let stickerPackItem = StickerPackItem(index: index, file: sticker, indexKeys: [])
|
||||
let item = ChatMediaInputStickerGridItem(account: strongSelf.account, collectionId: collectionId, stickerPackInfo: nil, index: ItemCollectionViewEntryIndex(collectionIndex: 0, collectionId: collectionId, itemIndex: index), stickerItem: stickerPackItem, canManagePeerSpecificPack: nil, interfaceInteraction: nil, inputNodeInteraction: inputNodeInteraction, hasAccessory: false, theme: interfaceState.theme, large: true, selected: {})
|
||||
let item = ChatMediaInputStickerGridItem(account: strongSelf.context.account, collectionId: collectionId, stickerPackInfo: nil, index: ItemCollectionViewEntryIndex(collectionIndex: 0, collectionId: collectionId, itemIndex: index), stickerItem: stickerPackItem, canManagePeerSpecificPack: nil, interfaceInteraction: nil, inputNodeInteraction: inputNodeInteraction, hasAccessory: false, theme: interfaceState.theme, large: true, selected: {})
|
||||
strongSelf.stickerItem = item
|
||||
strongSelf.stickerNode.updateLayout(item: item, size: stickerSize, isVisible: true, synchronousLoads: true)
|
||||
strongSelf.stickerNode.isVisibleInGrid = true
|
||||
@ -234,7 +235,7 @@ private final class ChatEmptyNodeGreetingChatContent: ASDisplayNode, ChatEmptyNo
|
||||
}
|
||||
|
||||
private final class ChatEmptyNodeNearbyChatContent: ASDisplayNode, ChatEmptyNodeContent, UIGestureRecognizerDelegate {
|
||||
private let account: Account
|
||||
private let context: AccountContext
|
||||
private let interaction: ChatPanelInterfaceInteraction?
|
||||
|
||||
private let titleNode: ImmediateTextNode
|
||||
@ -259,8 +260,8 @@ private final class ChatEmptyNodeNearbyChatContent: ASDisplayNode, ChatEmptyNode
|
||||
}
|
||||
}
|
||||
|
||||
init(account: Account, interaction: ChatPanelInterfaceInteraction?) {
|
||||
self.account = account
|
||||
init(context: AccountContext, interaction: ChatPanelInterfaceInteraction?) {
|
||||
self.context = context
|
||||
self.interaction = interaction
|
||||
|
||||
self.titleNode = ImmediateTextNode()
|
||||
@ -339,7 +340,7 @@ private final class ChatEmptyNodeNearbyChatContent: ASDisplayNode, ChatEmptyNode
|
||||
if let preloadedSticker = interfaceState.greetingData?.sticker {
|
||||
sticker = .single(preloadedSticker)
|
||||
} else {
|
||||
sticker = randomGreetingSticker(account: self.account)
|
||||
sticker = self.context.engine.stickers.randomGreetingSticker()
|
||||
|> map { item -> TelegramMediaFile? in
|
||||
return item?.file
|
||||
}
|
||||
@ -372,7 +373,7 @@ private final class ChatEmptyNodeNearbyChatContent: ASDisplayNode, ChatEmptyNode
|
||||
let index = ItemCollectionItemIndex(index: 0, id: 0)
|
||||
let collectionId = ItemCollectionId(namespace: 0, id: 0)
|
||||
let stickerPackItem = StickerPackItem(index: index, file: sticker, indexKeys: [])
|
||||
let item = ChatMediaInputStickerGridItem(account: strongSelf.account, collectionId: collectionId, stickerPackInfo: nil, index: ItemCollectionViewEntryIndex(collectionIndex: 0, collectionId: collectionId, itemIndex: index), stickerItem: stickerPackItem, canManagePeerSpecificPack: nil, interfaceInteraction: nil, inputNodeInteraction: inputNodeInteraction, hasAccessory: false, theme: interfaceState.theme, large: true, selected: {})
|
||||
let item = ChatMediaInputStickerGridItem(account: strongSelf.context.account, collectionId: collectionId, stickerPackInfo: nil, index: ItemCollectionViewEntryIndex(collectionIndex: 0, collectionId: collectionId, itemIndex: index), stickerItem: stickerPackItem, canManagePeerSpecificPack: nil, interfaceInteraction: nil, inputNodeInteraction: inputNodeInteraction, hasAccessory: false, theme: interfaceState.theme, large: true, selected: {})
|
||||
strongSelf.stickerItem = item
|
||||
strongSelf.stickerNode.updateLayout(item: item, size: stickerSize, isVisible: true, synchronousLoads: true)
|
||||
strongSelf.stickerNode.isVisibleInGrid = true
|
||||
@ -783,7 +784,7 @@ private enum ChatEmptyNodeContentType {
|
||||
}
|
||||
|
||||
final class ChatEmptyNode: ASDisplayNode {
|
||||
private let account: Account
|
||||
private let context: AccountContext
|
||||
private let interaction: ChatPanelInterfaceInteraction?
|
||||
|
||||
private let backgroundNode: ASImageNode
|
||||
@ -793,8 +794,8 @@ final class ChatEmptyNode: ASDisplayNode {
|
||||
|
||||
private var content: (ChatEmptyNodeContentType, ASDisplayNode & ChatEmptyNodeContent)?
|
||||
|
||||
init(account: Account, interaction: ChatPanelInterfaceInteraction?) {
|
||||
self.account = account
|
||||
init(context: AccountContext, interaction: ChatPanelInterfaceInteraction?) {
|
||||
self.context = context
|
||||
self.interaction = interaction
|
||||
|
||||
self.backgroundNode = ASImageNode()
|
||||
@ -827,7 +828,7 @@ final class ChatEmptyNode: ASDisplayNode {
|
||||
if case .replyThread = interfaceState.chatLocation {
|
||||
contentType = .regular
|
||||
} else if let peer = interfaceState.renderedPeer?.peer, !isScheduledMessages {
|
||||
if peer.id == self.account.peerId {
|
||||
if peer.id == self.context.account.peerId {
|
||||
contentType = .cloud
|
||||
} else if let _ = peer as? TelegramSecretChat {
|
||||
contentType = .secret
|
||||
@ -872,9 +873,9 @@ final class ChatEmptyNode: ASDisplayNode {
|
||||
case .cloud:
|
||||
node = ChatEmptyNodeCloudChatContent()
|
||||
case .peerNearby:
|
||||
node = ChatEmptyNodeNearbyChatContent(account: self.account, interaction: self.interaction)
|
||||
node = ChatEmptyNodeNearbyChatContent(context: self.context, interaction: self.interaction)
|
||||
case .greeting:
|
||||
node = ChatEmptyNodeGreetingChatContent(account: self.account, interaction: self.interaction)
|
||||
node = ChatEmptyNodeGreetingChatContent(context: self.context, interaction: self.interaction)
|
||||
}
|
||||
self.content = (contentType, node)
|
||||
self.addSubnode(node)
|
||||
|
@ -790,7 +790,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
||||
}
|
||||
|> distinctUntilChanged
|
||||
|
||||
let animatedEmojiStickers = loadedStickerPack(postbox: context.account.postbox, network: context.account.network, reference: .animatedEmoji, forceActualized: false)
|
||||
let animatedEmojiStickers = context.engine.stickers.loadedStickerPack(reference: .animatedEmoji, forceActualized: false)
|
||||
|> map { animatedEmoji -> [String: [StickerPackItem]] in
|
||||
var animatedEmojiStickers: [String: [StickerPackItem]] = [:]
|
||||
switch animatedEmoji {
|
||||
|
@ -127,7 +127,7 @@ private func updatedContextQueryResultStateForQuery(context: AccountContext, pee
|
||||
case .installed:
|
||||
scope = [.installed]
|
||||
}
|
||||
return searchStickers(account: context.account, query: query.basicEmoji.0, scope: scope)
|
||||
return context.engine.stickers.searchStickers(query: query.basicEmoji.0, scope: scope)
|
||||
|> castError(ChatContextQueryError.self)
|
||||
}
|
||||
|> map { stickers -> (ChatPresentationInputQueryResult?) -> ChatPresentationInputQueryResult? in
|
||||
@ -338,13 +338,13 @@ private func updatedContextQueryResultStateForQuery(context: AccountContext, pee
|
||||
|
||||
return signal |> then(contextBot)
|
||||
case let .emojiSearch(query, languageCode, range):
|
||||
var signal = searchEmojiKeywords(postbox: context.account.postbox, inputLanguageCode: languageCode, query: query, completeMatch: query.count < 2)
|
||||
var signal = context.engine.stickers.searchEmojiKeywords(inputLanguageCode: languageCode, query: query, completeMatch: query.count < 2)
|
||||
if !languageCode.lowercased().hasPrefix("en") {
|
||||
signal = signal
|
||||
|> mapToSignal { keywords in
|
||||
return .single(keywords)
|
||||
|> then(
|
||||
searchEmojiKeywords(postbox: context.account.postbox, inputLanguageCode: "en-US", query: query, completeMatch: query.count < 3)
|
||||
context.engine.stickers.searchEmojiKeywords(inputLanguageCode: "en-US", query: query, completeMatch: query.count < 3)
|
||||
|> map { englishKeywords in
|
||||
return keywords + englishKeywords
|
||||
}
|
||||
|
@ -783,14 +783,14 @@ final class ChatMediaInputNode: ChatInputNode {
|
||||
guard let strongSelf = self, let info = info as? StickerPackCollectionInfo else {
|
||||
return
|
||||
}
|
||||
let _ = (loadedStickerPack(postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network, reference: .id(id: info.id.id, accessHash: info.accessHash), forceActualized: false)
|
||||
let _ = (context.engine.stickers.loadedStickerPack(reference: .id(id: info.id.id, accessHash: info.accessHash), forceActualized: false)
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
switch result {
|
||||
case let .result(info, items, installed):
|
||||
if installed {
|
||||
return .complete()
|
||||
} else {
|
||||
return addStickerPackInteractively(postbox: strongSelf.context.account.postbox, info: info, items: items)
|
||||
return context.engine.stickers.addStickerPackInteractively(info: info, items: items)
|
||||
}
|
||||
case .fetching:
|
||||
break
|
||||
|
@ -245,23 +245,22 @@ final class ChatMediaInputTrendingPane: ChatMediaInputPane {
|
||||
|
||||
let interaction = TrendingPaneInteraction(installPack: { [weak self] info in
|
||||
if let strongSelf = self, let info = info as? StickerPackCollectionInfo {
|
||||
let account = strongSelf.context.account
|
||||
var installSignal = loadedStickerPack(postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network, reference: .id(id: info.id.id, accessHash: info.accessHash), forceActualized: false)
|
||||
let context = strongSelf.context
|
||||
var installSignal = context.engine.stickers.loadedStickerPack(reference: .id(id: info.id.id, accessHash: info.accessHash), forceActualized: false)
|
||||
|> mapToSignal { result -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> in
|
||||
switch result {
|
||||
case let .result(info, items, installed):
|
||||
if installed {
|
||||
return .complete()
|
||||
} else {
|
||||
return preloadedStickerPackThumbnail(account: account, info: info, items: items)
|
||||
return preloadedStickerPackThumbnail(account: context.account, info: info, items: items)
|
||||
|> filter { $0 }
|
||||
|> ignoreValues
|
||||
|> then(
|
||||
addStickerPackInteractively(postbox: strongSelf.context.account.postbox, info: info, items: items)
|
||||
context.engine.stickers.addStickerPackInteractively(info: info, items: items)
|
||||
|> ignoreValues
|
||||
)
|
||||
|> mapToSignal { _ -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> in
|
||||
return .complete()
|
||||
}
|
||||
|> then(.single((info, items)))
|
||||
}
|
||||
@ -273,8 +272,7 @@ final class ChatMediaInputTrendingPane: ChatMediaInputPane {
|
||||
return .complete()
|
||||
}
|
||||
|> deliverOnMainQueue
|
||||
|
||||
let context = strongSelf.context
|
||||
|
||||
var cancelImpl: (() -> Void)?
|
||||
let progressSignal = Signal<Never, NoError> { subscriber in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
@ -318,7 +316,7 @@ final class ChatMediaInputTrendingPane: ChatMediaInputPane {
|
||||
}
|
||||
|
||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||
strongSelf.controllerInteraction.navigationController()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, account: strongSelf.context.account), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
strongSelf.controllerInteraction.navigationController()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, context: strongSelf.context), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
return true
|
||||
}))
|
||||
}))
|
||||
|
@ -679,7 +679,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
func animateReplyPanel(sourceReplyPanel: ChatMessageTransitionNode.ReplyPanel, transition: ContainedViewLayoutTransition) {
|
||||
if let replyInfoNode = self.replyInfoNode {
|
||||
let localRect = self.mainContextSourceNode.contentNode.view.convert(sourceReplyPanel.relativeSourceRect, to: replyInfoNode.view)
|
||||
replyInfoNode.animateFromInputPanel(sourceReplyPanel: sourceReplyPanel, localRect: localRect, transition: transition)
|
||||
let _ = replyInfoNode.animateFromInputPanel(sourceReplyPanel: sourceReplyPanel, localRect: localRect, transition: transition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -644,10 +644,10 @@ class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
func animateFrom(sourceView: UIView, widthDifference: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||
self.view.addSubview(sourceView)
|
||||
|
||||
sourceView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.15, removeOnCompletion: false, completion: { [weak sourceView] _ in
|
||||
sourceView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.1, removeOnCompletion: false, completion: { [weak sourceView] _ in
|
||||
sourceView?.removeFromSuperview()
|
||||
})
|
||||
self.textNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.1)
|
||||
self.textNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.08)
|
||||
|
||||
let offset = CGPoint(
|
||||
x: sourceView.frame.minX - (self.textNode.frame.minX - 0.0),
|
||||
|
@ -9,6 +9,7 @@ import WebPBinding
|
||||
import MediaResources
|
||||
import Emoji
|
||||
import AppBundle
|
||||
import AccountContext
|
||||
|
||||
public struct EmojiThumbnailResourceId: MediaResourceId {
|
||||
public let emoji: String
|
||||
@ -284,17 +285,17 @@ private final class Buffer {
|
||||
var data = Data()
|
||||
}
|
||||
|
||||
func fetchEmojiSpriteResource(postbox: Postbox, network: Network, resource: EmojiSpriteResource) -> Signal<MediaResourceDataFetchResult, MediaResourceDataFetchError> {
|
||||
func fetchEmojiSpriteResource(account: Account, resource: EmojiSpriteResource) -> Signal<MediaResourceDataFetchResult, MediaResourceDataFetchError> {
|
||||
let packName = "P\(resource.packId)_by_AEStickerBot"
|
||||
|
||||
return loadedStickerPack(postbox: postbox, network: network, reference: .name(packName), forceActualized: false)
|
||||
return TelegramEngine(account: account).stickers.loadedStickerPack(reference: .name(packName), forceActualized: false)
|
||||
|> castError(MediaResourceDataFetchError.self)
|
||||
|> mapToSignal { result -> Signal<MediaResourceDataFetchResult, MediaResourceDataFetchError> in
|
||||
switch result {
|
||||
case let .result(_, items, _):
|
||||
if let sticker = items[Int(resource.stickerId)] as? StickerPackItem {
|
||||
return Signal { subscriber in
|
||||
guard let fetchResource = postbox.mediaBox.fetchResource else {
|
||||
guard let fetchResource = account.postbox.mediaBox.fetchResource else {
|
||||
return EmptyDisposable
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ private final class FeaturedStickersScreenNode: ViewControllerTracingNode {
|
||||
}
|
||||
}
|
||||
if !addedRead.isEmpty {
|
||||
let _ = markFeaturedStickerPacksAsSeenInteractively(postbox: strongSelf.context.account.postbox, ids: addedRead).start()
|
||||
let _ = strongSelf.context.engine.stickers.markFeaturedStickerPacksAsSeenInteractively(ids: addedRead).start()
|
||||
}
|
||||
|
||||
if bottomIndex >= strongSelf.gridNode.items.count - 15 {
|
||||
@ -295,84 +295,9 @@ private final class FeaturedStickersScreenNode: ViewControllerTracingNode {
|
||||
}
|
||||
let account = strongSelf.context.account
|
||||
if install {
|
||||
let _ = addStickerPackInteractively(postbox: strongSelf.context.account.postbox, info: info, items: []).start()
|
||||
/*var installSignal = loadedStickerPack(postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network, reference: .id(id: info.id.id, accessHash: info.accessHash), forceActualized: false)
|
||||
|> mapToSignal { result -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> in
|
||||
switch result {
|
||||
case let .result(info, items, installed):
|
||||
if installed {
|
||||
return .complete()
|
||||
} else {
|
||||
return preloadedStickerPackThumbnail(account: account, info: info, items: items)
|
||||
|> filter { $0 }
|
||||
|> ignoreValues
|
||||
|> then(
|
||||
addStickerPackInteractively(postbox: strongSelf.context.account.postbox, info: info, items: items)
|
||||
|> ignoreValues
|
||||
)
|
||||
|> mapToSignal { _ -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> in
|
||||
}
|
||||
|> then(.single((info, items)))
|
||||
}
|
||||
case .fetching:
|
||||
break
|
||||
case .none:
|
||||
break
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
|> deliverOnMainQueue
|
||||
|
||||
let context = strongSelf.context
|
||||
var cancelImpl: (() -> Void)?
|
||||
let progressSignal = Signal<Never, NoError> { subscriber in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: {
|
||||
cancelImpl?()
|
||||
}))
|
||||
self?.controller?.present(controller, in: .window(.root))
|
||||
return ActionDisposable { [weak controller] in
|
||||
Queue.mainQueue().async() {
|
||||
controller?.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|> runOn(Queue.mainQueue())
|
||||
|> delay(1.0, queue: Queue.mainQueue())
|
||||
let progressDisposable = progressSignal.start()
|
||||
|
||||
installSignal = installSignal
|
||||
|> afterDisposed {
|
||||
Queue.mainQueue().async {
|
||||
progressDisposable.dispose()
|
||||
}
|
||||
}
|
||||
cancelImpl = {
|
||||
self?.installDisposable.set(nil)
|
||||
}
|
||||
|
||||
strongSelf.installDisposable.set(installSignal.start(next: { info, items in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
/*var animateInAsReplacement = false
|
||||
if let navigationController = strongSelf.controllerInteraction.navigationController() {
|
||||
for controller in navigationController.overlayControllers {
|
||||
if let controller = controller as? UndoOverlayController {
|
||||
controller.dismissWithCommitActionAndReplacementAnimation()
|
||||
animateInAsReplacement = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||
strongSelf.controllerInteraction.navigationController()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, account: strongSelf.context.account), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
return true
|
||||
}))*/
|
||||
}))*/
|
||||
let _ = strongSelf.context.engine.stickers.addStickerPackInteractively(info: info, items: []).start()
|
||||
} else {
|
||||
let _ = (removeStickerPackInteractively(postbox: account.postbox, id: info.id, option: .delete)
|
||||
let _ = (strongSelf.context.engine.stickers.removeStickerPackInteractively(id: info.id, option: .delete)
|
||||
|> deliverOnMainQueue).start(next: { _ in
|
||||
})
|
||||
}
|
||||
@ -1165,85 +1090,9 @@ private final class FeaturedPaneSearchContentNode: ASDisplayNode {
|
||||
}
|
||||
let account = strongSelf.context.account
|
||||
if install {
|
||||
let _ = addStickerPackInteractively(postbox: strongSelf.context.account.postbox, info: info, items: []).start()
|
||||
/*var installSignal = loadedStickerPack(postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network, reference: .id(id: info.id.id, accessHash: info.accessHash), forceActualized: false)
|
||||
|> mapToSignal { result -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> in
|
||||
switch result {
|
||||
case let .result(info, items, installed):
|
||||
if installed {
|
||||
return .complete()
|
||||
} else {
|
||||
return preloadedStickerPackThumbnail(account: account, info: info, items: items)
|
||||
|> filter { $0 }
|
||||
|> ignoreValues
|
||||
|> then(
|
||||
addStickerPackInteractively(postbox: strongSelf.context.account.postbox, info: info, items: items)
|
||||
|> ignoreValues
|
||||
)
|
||||
|> mapToSignal { _ -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> in
|
||||
return .complete()
|
||||
}
|
||||
|> then(.single((info, items)))
|
||||
}
|
||||
case .fetching:
|
||||
break
|
||||
case .none:
|
||||
break
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
|> deliverOnMainQueue
|
||||
|
||||
let context = strongSelf.context
|
||||
var cancelImpl: (() -> Void)?
|
||||
let progressSignal = Signal<Never, NoError> { subscriber in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: {
|
||||
cancelImpl?()
|
||||
}))
|
||||
self?.controller?.present(controller, in: .window(.root))
|
||||
return ActionDisposable { [weak controller] in
|
||||
Queue.mainQueue().async() {
|
||||
controller?.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|> runOn(Queue.mainQueue())
|
||||
|> delay(0.12, queue: Queue.mainQueue())
|
||||
let progressDisposable = progressSignal.start()
|
||||
|
||||
installSignal = installSignal
|
||||
|> afterDisposed {
|
||||
Queue.mainQueue().async {
|
||||
progressDisposable.dispose()
|
||||
}
|
||||
}
|
||||
cancelImpl = {
|
||||
self?.installDisposable.set(nil)
|
||||
}
|
||||
|
||||
strongSelf.installDisposable.set(installSignal.start(next: { info, items in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
var animateInAsReplacement = false
|
||||
if let navigationController = strongSelf.controller?.navigationController as? NavigationController {
|
||||
for controller in navigationController.overlayControllers {
|
||||
if let controller = controller as? UndoOverlayController {
|
||||
controller.dismissWithCommitActionAndReplacementAnimation()
|
||||
animateInAsReplacement = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||
/*strongSelf.controllerInteraction.navigationController()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, account: strongSelf.context.account), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
return true
|
||||
}))*/
|
||||
}))*/
|
||||
let _ = strongSelf.context.engine.stickers.addStickerPackInteractively(info: info, items: []).start()
|
||||
} else {
|
||||
let _ = (removeStickerPackInteractively(postbox: account.postbox, id: info.id, option: .delete)
|
||||
let _ = (strongSelf.context.engine.stickers.removeStickerPackInteractively(id: info.id, option: .delete)
|
||||
|> deliverOnMainQueue).start(next: { _ in
|
||||
})
|
||||
}
|
||||
@ -1268,22 +1117,22 @@ private final class FeaturedPaneSearchContentNode: ASDisplayNode {
|
||||
func updateText(_ text: String, languageCode: String?) {
|
||||
let signal: Signal<([(String?, FoundStickerItem)], FoundStickerSets, Bool, FoundStickerSets?)?, NoError>
|
||||
if !text.isEmpty {
|
||||
let account = self.context.account
|
||||
let context = self.context
|
||||
let stickers: Signal<[(String?, FoundStickerItem)], NoError> = Signal { subscriber in
|
||||
var signals: Signal<[Signal<(String?, [FoundStickerItem]), NoError>], NoError> = .single([])
|
||||
|
||||
let query = text.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if query.isSingleEmoji {
|
||||
signals = .single([searchStickers(account: account, query: text.basicEmoji.0)
|
||||
signals = .single([context.engine.stickers.searchStickers(query: text.basicEmoji.0)
|
||||
|> map { (nil, $0) }])
|
||||
} else if query.count > 1, let languageCode = languageCode, !languageCode.isEmpty && languageCode != "emoji" {
|
||||
var signal = searchEmojiKeywords(postbox: account.postbox, inputLanguageCode: languageCode, query: query.lowercased(), completeMatch: query.count < 3)
|
||||
var signal = context.engine.stickers.searchEmojiKeywords(inputLanguageCode: languageCode, query: query.lowercased(), completeMatch: query.count < 3)
|
||||
if !languageCode.lowercased().hasPrefix("en") {
|
||||
signal = signal
|
||||
|> mapToSignal { keywords in
|
||||
return .single(keywords)
|
||||
|> then(
|
||||
searchEmojiKeywords(postbox: account.postbox, inputLanguageCode: "en-US", query: query.lowercased(), completeMatch: query.count < 3)
|
||||
context.engine.stickers.searchEmojiKeywords(inputLanguageCode: "en-US", query: query.lowercased(), completeMatch: query.count < 3)
|
||||
|> map { englishKeywords in
|
||||
return keywords + englishKeywords
|
||||
}
|
||||
@ -1296,7 +1145,7 @@ private final class FeaturedPaneSearchContentNode: ASDisplayNode {
|
||||
var signals: [Signal<(String?, [FoundStickerItem]), NoError>] = []
|
||||
let emoticons = keywords.flatMap { $0.emoticons }
|
||||
for emoji in emoticons {
|
||||
signals.append(searchStickers(account: self.context.account, query: emoji.basicEmoji.0)
|
||||
signals.append(context.engine.stickers.searchStickers(query: emoji.basicEmoji.0)
|
||||
|> take(1)
|
||||
|> map { (emoji, $0) })
|
||||
}
|
||||
@ -1320,8 +1169,8 @@ private final class FeaturedPaneSearchContentNode: ASDisplayNode {
|
||||
})
|
||||
}
|
||||
|
||||
let local = searchStickerSets(postbox: context.account.postbox, query: text)
|
||||
let remote = searchStickerSetsRemotely(network: context.account.network, query: text)
|
||||
let local = context.engine.stickers.searchStickerSets(query: text)
|
||||
let remote = context.engine.stickers.searchStickerSetsRemotely(query: text)
|
||||
|> delay(0.2, queue: Queue.mainQueue())
|
||||
let rawPacks = local
|
||||
|> mapToSignal { result -> Signal<(FoundStickerSets, Bool, FoundStickerSets?), NoError> in
|
||||
|
@ -137,7 +137,7 @@ final class ManagedDiceAnimationNode: ManagedAnimationNode, GenericAnimatedStick
|
||||
let appConfiguration: AppConfiguration = preferencesView.values[PreferencesKeys.appConfiguration] as? AppConfiguration ?? .defaultValue
|
||||
return InteractiveEmojiConfiguration.with(appConfiguration: appConfiguration)
|
||||
})
|
||||
self.emojis.set(loadedStickerPack(postbox: context.account.postbox, network: context.account.network, reference: .dice(emoji), forceActualized: false)
|
||||
self.emojis.set(context.engine.stickers.loadedStickerPack(reference: .dice(emoji), forceActualized: false)
|
||||
|> mapToSignal { stickerPack -> Signal<[TelegramMediaFile], NoError> in
|
||||
switch stickerPack {
|
||||
case let .result(_, items, _):
|
||||
|
@ -92,13 +92,13 @@ func openChatMessageImpl(_ params: OpenChatMessageParams) -> Bool {
|
||||
}
|
||||
switch action {
|
||||
case .add:
|
||||
params.navigationController?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, account: params.context.account), elevatedLayout: true, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
params.navigationController?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, context: params.context), elevatedLayout: true, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
return true
|
||||
}))
|
||||
case let .remove(positionInList):
|
||||
params.navigationController?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_RemovedTitle, text: presentationData.strings.StickerPackActionInfo_RemovedText(info.title).0, undo: true, info: info, topItem: items.first, account: params.context.account), elevatedLayout: true, animateInAsReplacement: animateInAsReplacement, action: { action in
|
||||
params.navigationController?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_RemovedTitle, text: presentationData.strings.StickerPackActionInfo_RemovedText(info.title).0, undo: true, info: info, topItem: items.first, context: params.context), elevatedLayout: true, animateInAsReplacement: animateInAsReplacement, action: { action in
|
||||
if case .undo = action {
|
||||
let _ = addStickerPackInteractively(postbox: params.context.account.postbox, info: info, items: items, positionInList: positionInList).start()
|
||||
let _ = params.context.engine.stickers.addStickerPackInteractively(info: info, items: items, positionInList: positionInList).start()
|
||||
}
|
||||
return true
|
||||
}))
|
||||
|
@ -2733,7 +2733,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
|> map(Optional.init)
|
||||
))
|
||||
self.privacySettings.set(.single(nil) |> then(requestAccountPrivacySettings(account: context.account) |> map(Optional.init)))
|
||||
self.archivedPacks.set(.single(nil) |> then(archivedStickerPacks(account: context.account) |> map(Optional.init)))
|
||||
self.archivedPacks.set(.single(nil) |> then(context.engine.stickers.archivedStickerPacks() |> map(Optional.init)))
|
||||
self.hasPassport.set(.single(false) |> then(twoStepAuthData(context.account.network)
|
||||
|> map { value -> Bool in
|
||||
return value.hasSecretValues
|
||||
@ -2834,7 +2834,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
self.preloadHistoryDisposable.set(self.context.account.addAdditionalPreloadHistoryPeerId(peerId: peerId))
|
||||
|
||||
self.preloadedSticker.set(.single(nil)
|
||||
|> then(randomGreetingSticker(account: context.account)
|
||||
|> then(context.engine.stickers.randomGreetingSticker()
|
||||
|> map { item in
|
||||
return item?.file
|
||||
}))
|
||||
|
@ -52,7 +52,7 @@ private final class PrefetchManagerImpl {
|
||||
return view.values[PreferencesKeys.appConfiguration] as? AppConfiguration ?? .defaultValue
|
||||
}
|
||||
|
||||
let orderedPreloadMedia = combineLatest(account.viewTracker.orderedPreloadMedia, loadedStickerPack(postbox: account.postbox, network: account.network, reference: .animatedEmoji, forceActualized: false), appConfiguration)
|
||||
let orderedPreloadMedia = combineLatest(account.viewTracker.orderedPreloadMedia, TelegramEngine(account: account).stickers.loadedStickerPack(reference: .animatedEmoji, forceActualized: false), appConfiguration)
|
||||
|> map { orderedPreloadMedia, stickerPack, appConfiguration -> [PrefetchMediaItem] in
|
||||
let emojiSounds = AnimatedEmojiSoundsConfiguration.with(appConfiguration: appConfiguration, account: account)
|
||||
let chatHistoryMediaItems = orderedPreloadMedia.map { PrefetchMediaItem.chatHistory($0) }
|
||||
|
@ -238,24 +238,23 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
let account = strongSelf.context.account
|
||||
let context = strongSelf.context
|
||||
if install {
|
||||
var installSignal = loadedStickerPack(postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network, reference: .id(id: info.id.id, accessHash: info.accessHash), forceActualized: false)
|
||||
var installSignal = strongSelf.context.engine.stickers.loadedStickerPack(reference: .id(id: info.id.id, accessHash: info.accessHash), forceActualized: false)
|
||||
|> mapToSignal { result -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> in
|
||||
switch result {
|
||||
case let .result(info, items, installed):
|
||||
if installed {
|
||||
return .complete()
|
||||
} else {
|
||||
return preloadedStickerPackThumbnail(account: account, info: info, items: items)
|
||||
return preloadedStickerPackThumbnail(account: context.account, info: info, items: items)
|
||||
|> filter { $0 }
|
||||
|> ignoreValues
|
||||
|> then(
|
||||
addStickerPackInteractively(postbox: strongSelf.context.account.postbox, info: info, items: items)
|
||||
context.engine.stickers.addStickerPackInteractively(info: info, items: items)
|
||||
|> ignoreValues
|
||||
)
|
||||
|> mapToSignal { _ -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> in
|
||||
return .complete()
|
||||
}
|
||||
|> then(.single((info, items)))
|
||||
}
|
||||
@ -312,12 +311,12 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
|
||||
}
|
||||
|
||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||
strongSelf.controllerInteraction.navigationController()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, account: strongSelf.context.account), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
strongSelf.controllerInteraction.navigationController()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).0, undo: false, info: info, topItem: items.first, context: strongSelf.context), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
return true
|
||||
}))
|
||||
}))
|
||||
} else {
|
||||
let _ = (removeStickerPackInteractively(postbox: account.postbox, id: info.id, option: .delete)
|
||||
let _ = (context.engine.stickers.removeStickerPackInteractively(id: info.id, option: .delete)
|
||||
|> deliverOnMainQueue).start(next: { _ in
|
||||
})
|
||||
}
|
||||
@ -343,22 +342,22 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
|
||||
func updateText(_ text: String, languageCode: String?) {
|
||||
let signal: Signal<([(String?, FoundStickerItem)], FoundStickerSets, Bool, FoundStickerSets?)?, NoError>
|
||||
if !text.isEmpty {
|
||||
let account = self.context.account
|
||||
let context = self.context
|
||||
let stickers: Signal<[(String?, FoundStickerItem)], NoError> = Signal { subscriber in
|
||||
var signals: Signal<[Signal<(String?, [FoundStickerItem]), NoError>], NoError> = .single([])
|
||||
|
||||
let query = text.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if query.isSingleEmoji {
|
||||
signals = .single([searchStickers(account: account, query: text.basicEmoji.0)
|
||||
signals = .single([context.engine.stickers.searchStickers(query: text.basicEmoji.0)
|
||||
|> map { (nil, $0) }])
|
||||
} else if query.count > 1, let languageCode = languageCode, !languageCode.isEmpty && languageCode != "emoji" {
|
||||
var signal = searchEmojiKeywords(postbox: account.postbox, inputLanguageCode: languageCode, query: query.lowercased(), completeMatch: query.count < 3)
|
||||
var signal = context.engine.stickers.searchEmojiKeywords(inputLanguageCode: languageCode, query: query.lowercased(), completeMatch: query.count < 3)
|
||||
if !languageCode.lowercased().hasPrefix("en") {
|
||||
signal = signal
|
||||
|> mapToSignal { keywords in
|
||||
return .single(keywords)
|
||||
|> then(
|
||||
searchEmojiKeywords(postbox: account.postbox, inputLanguageCode: "en-US", query: query.lowercased(), completeMatch: query.count < 3)
|
||||
context.engine.stickers.searchEmojiKeywords(inputLanguageCode: "en-US", query: query.lowercased(), completeMatch: query.count < 3)
|
||||
|> map { englishKeywords in
|
||||
return keywords + englishKeywords
|
||||
}
|
||||
@ -371,7 +370,7 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
|
||||
var signals: [Signal<(String?, [FoundStickerItem]), NoError>] = []
|
||||
let emoticons = keywords.flatMap { $0.emoticons }
|
||||
for emoji in emoticons {
|
||||
signals.append(searchStickers(account: self.context.account, query: emoji.basicEmoji.0)
|
||||
signals.append(context.engine.stickers.searchStickers(query: emoji.basicEmoji.0)
|
||||
|> take(1)
|
||||
|> map { (emoji, $0) })
|
||||
}
|
||||
@ -395,8 +394,8 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
|
||||
})
|
||||
}
|
||||
|
||||
let local = searchStickerSets(postbox: context.account.postbox, query: text)
|
||||
let remote = searchStickerSetsRemotely(network: context.account.network, query: text)
|
||||
let local = context.engine.stickers.searchStickerSets(query: text)
|
||||
let remote = context.engine.stickers.searchStickerSetsRemotely(query: text)
|
||||
|> delay(0.2, queue: Queue.mainQueue())
|
||||
let rawPacks = local
|
||||
|> mapToSignal { result -> Signal<(FoundStickerSets, Bool, FoundStickerSets?), NoError> in
|
||||
|
@ -36,7 +36,7 @@ public let telegramAccountAuxiliaryMethods = AccountAuxiliaryMethods(updatePeerC
|
||||
} else if let resource = resource as? OpenInAppIconResource {
|
||||
return fetchOpenInAppIconResource(resource: resource)
|
||||
} else if let resource = resource as? EmojiSpriteResource {
|
||||
return fetchEmojiSpriteResource(postbox: account.postbox, network: account.network, resource: resource)
|
||||
return fetchEmojiSpriteResource(account: account, resource: resource)
|
||||
} else if let resource = resource as? VenueIconResource {
|
||||
return fetchVenueIconResource(account: account, resource: resource)
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ public enum UndoOverlayContent {
|
||||
case emoji(path: String, text: String)
|
||||
case swipeToReply(title: String, text: String)
|
||||
case actionSucceeded(title: String, text: String, cancel: String)
|
||||
case stickersModified(title: String, text: String, undo: Bool, info: StickerPackCollectionInfo, topItem: ItemCollectionItem?, account: Account)
|
||||
case dice(dice: TelegramMediaDice, account: Account, text: String, action: String?)
|
||||
case stickersModified(title: String, text: String, undo: Bool, info: StickerPackCollectionInfo, topItem: ItemCollectionItem?, context: AccountContext)
|
||||
case dice(dice: TelegramMediaDice, context: AccountContext, text: String, action: String?)
|
||||
case chatAddedToFolder(chatTitle: String, folderTitle: String)
|
||||
case chatRemovedFromFolder(chatTitle: String, folderTitle: String)
|
||||
case messagesUnpinned(title: String, text: String, undo: Bool, isHidden: Bool)
|
||||
@ -35,7 +35,7 @@ public enum UndoOverlayContent {
|
||||
case voiceChatRecording(text: String)
|
||||
case voiceChatFlag(text: String)
|
||||
case voiceChatCanSpeak(text: String)
|
||||
case sticker(account: Account, file: TelegramMediaFile, text: String)
|
||||
case sticker(context: AccountContext, file: TelegramMediaFile, text: String)
|
||||
case copy(text: String)
|
||||
case mediaSaved(text: String)
|
||||
case paymentSent(currencyValue: String, itemTitle: String)
|
||||
|
@ -17,6 +17,7 @@ import SlotMachineAnimationNode
|
||||
import AnimationUI
|
||||
import StickerResources
|
||||
import AvatarNode
|
||||
import AccountContext
|
||||
|
||||
final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
private let elevatedLayout: Bool
|
||||
@ -330,7 +331,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
self.textNode.maximumNumberOfLines = 2
|
||||
displayUndo = false
|
||||
self.originalRemainingSeconds = 5
|
||||
case let .stickersModified(title, text, undo, info, topItem, account):
|
||||
case let .stickersModified(title, text, undo, info, topItem, context):
|
||||
self.avatarNode = nil
|
||||
self.iconNode = nil
|
||||
self.iconCheckNode = nil
|
||||
@ -377,14 +378,14 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
let stillImageSize = representation.dimensions.cgSize.aspectFitted(imageBoundingSize)
|
||||
self.stickerImageSize = stillImageSize
|
||||
|
||||
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: account.postbox, resource: representation.resource)
|
||||
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: context.account.postbox, resource: representation.resource)
|
||||
case let .animated(resource):
|
||||
self.stickerImageSize = imageBoundingSize
|
||||
|
||||
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: account.postbox, resource: resource, animated: true)
|
||||
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: context.account.postbox, resource: resource, animated: true)
|
||||
}
|
||||
if let resourceReference = resourceReference {
|
||||
updatedFetchSignal = fetchedMediaResource(mediaBox: account.postbox.mediaBox, reference: resourceReference)
|
||||
updatedFetchSignal = fetchedMediaResource(mediaBox: context.account.postbox.mediaBox, reference: resourceReference)
|
||||
}
|
||||
} else {
|
||||
updatedImageSignal = .single({ _ in return nil })
|
||||
@ -415,10 +416,10 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
case let .animated(resource):
|
||||
let animatedStickerNode = AnimatedStickerNode()
|
||||
self.animatedStickerNode = animatedStickerNode
|
||||
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: account, resource: resource), width: 80, height: 80, mode: .cached)
|
||||
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: context.account, resource: resource), width: 80, height: 80, mode: .cached)
|
||||
}
|
||||
}
|
||||
case let .dice(dice, account, text, action):
|
||||
case let .dice(dice, context, text, action):
|
||||
self.avatarNode = nil
|
||||
self.iconNode = nil
|
||||
self.iconCheckNode = nil
|
||||
@ -458,14 +459,14 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
let animatedStickerNode = AnimatedStickerNode()
|
||||
self.animatedStickerNode = animatedStickerNode
|
||||
|
||||
let _ = (loadedStickerPack(postbox: account.postbox, network: account.network, reference: .dice(dice.emoji), forceActualized: false)
|
||||
let _ = (context.engine.stickers.loadedStickerPack(reference: .dice(dice.emoji), forceActualized: false)
|
||||
|> deliverOnMainQueue).start(next: { stickerPack in
|
||||
if let value = dice.value {
|
||||
switch stickerPack {
|
||||
case let .result(_, items, _):
|
||||
let item = items[Int(value)]
|
||||
if let item = item as? StickerPackItem {
|
||||
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: account, resource: item.file.resource), width: 120, height: 120, playbackMode: .once, mode: .direct(cachePathPrefix: nil))
|
||||
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: context.account, resource: item.file.resource), width: 120, height: 120, playbackMode: .once, mode: .direct(cachePathPrefix: nil))
|
||||
}
|
||||
default:
|
||||
break
|
||||
@ -613,7 +614,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
|
||||
displayUndo = false
|
||||
self.originalRemainingSeconds = 3
|
||||
case let .sticker(account, file, text):
|
||||
case let .sticker(context, file, text):
|
||||
self.avatarNode = nil
|
||||
self.iconNode = nil
|
||||
self.iconCheckNode = nil
|
||||
@ -650,14 +651,14 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
let stillImageSize = representation.dimensions.cgSize.aspectFitted(imageBoundingSize)
|
||||
self.stickerImageSize = stillImageSize
|
||||
|
||||
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: account.postbox, resource: representation.resource)
|
||||
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: context.account.postbox, resource: representation.resource)
|
||||
case let .animated(resource):
|
||||
self.stickerImageSize = imageBoundingSize
|
||||
|
||||
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: account.postbox, resource: resource, animated: true)
|
||||
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: context.account.postbox, resource: resource, animated: true)
|
||||
}
|
||||
if let resourceReference = resourceReference {
|
||||
updatedFetchSignal = fetchedMediaResource(mediaBox: account.postbox.mediaBox, reference: resourceReference)
|
||||
updatedFetchSignal = fetchedMediaResource(mediaBox: context.account.postbox.mediaBox, reference: resourceReference)
|
||||
}
|
||||
} else {
|
||||
updatedImageSignal = .single({ _ in return nil })
|
||||
@ -688,7 +689,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
||||
case let .animated(resource):
|
||||
let animatedStickerNode = AnimatedStickerNode()
|
||||
self.animatedStickerNode = animatedStickerNode
|
||||
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: account, resource: resource), width: 80, height: 80, mode: .cached)
|
||||
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: context.account, resource: resource), width: 80, height: 80, mode: .cached)
|
||||
}
|
||||
}
|
||||
case let .copy(text):
|
||||
|
Loading…
x
Reference in New Issue
Block a user