mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Enable premium suggestions in saved messages
This commit is contained in:
@@ -15,15 +15,20 @@ import TextFormat
|
||||
public final class EmojiSuggestionsComponent: Component {
|
||||
public typealias EnvironmentType = Empty
|
||||
|
||||
public static func suggestionData(context: AccountContext, query: String) -> Signal<[TelegramMediaFile], NoError> {
|
||||
let hasPremium = context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId))
|
||||
|> map { peer -> Bool in
|
||||
guard case let .user(user) = peer else {
|
||||
return false
|
||||
public static func suggestionData(context: AccountContext, isSavedMessages: Bool, query: String) -> Signal<[TelegramMediaFile], NoError> {
|
||||
let hasPremium: Signal<Bool, NoError>
|
||||
if isSavedMessages {
|
||||
hasPremium = .single(true)
|
||||
} else {
|
||||
hasPremium = context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId))
|
||||
|> map { peer -> Bool in
|
||||
guard case let .user(user) = peer else {
|
||||
return false
|
||||
}
|
||||
return user.isPremium
|
||||
}
|
||||
return user.isPremium
|
||||
|> distinctUntilChanged
|
||||
}
|
||||
|> distinctUntilChanged
|
||||
|
||||
return combineLatest(
|
||||
context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: [], namespaces: [Namespaces.ItemCollection.CloudEmojiPacks], aroundIndex: nil, count: 10000000),
|
||||
|
||||
@@ -2509,7 +2509,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
self.dismissedEmojiSuggestionPosition = nil
|
||||
|
||||
if beginRequest {
|
||||
suggestionContext.disposable.set((EmojiSuggestionsComponent.suggestionData(context: context, query: String(lastCharacter))
|
||||
suggestionContext.disposable.set((EmojiSuggestionsComponent.suggestionData(context: context, isSavedMessages: self.presentationInterfaceState?.chatLocation.peerId == self.context?.account.peerId, query: String(lastCharacter))
|
||||
|> deliverOnMainQueue).start(next: { [weak self, weak suggestionContext] result in
|
||||
guard let strongSelf = self, let suggestionContext = suggestionContext, strongSelf.currentEmojiSuggestion === suggestionContext else {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user