mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
[WIP] Quotes
This commit is contained in:
@@ -326,6 +326,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
var searchQuerySuggestionState: (ChatPresentationInputQuery?, Disposable)?
|
||||
var urlPreviewQueryState: (String?, Disposable)?
|
||||
var editingUrlPreviewQueryState: (String?, Disposable)?
|
||||
var replyMessageState: (EngineMessage.Id, Disposable)?
|
||||
var searchState: ChatSearchState?
|
||||
|
||||
var shakeFeedback: HapticFeedback?
|
||||
@@ -618,7 +619,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|
||||
self.stickerSettings = ChatInterfaceStickerSettings()
|
||||
|
||||
self.presentationInterfaceState = ChatPresentationInterfaceState(chatWallpaper: self.presentationData.chatWallpaper, theme: self.presentationData.theme, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameDisplayOrder: self.presentationData.nameDisplayOrder, limitsConfiguration: context.currentLimitsConfiguration.with { $0 }, fontSize: self.presentationData.chatFontSize, bubbleCorners: self.presentationData.chatBubbleCorners, accountPeerId: context.account.peerId, mode: mode, chatLocation: chatLocation, subject: subject, peerNearbyData: peerNearbyData, greetingData: context.prefetchManager?.preloadedGreetingSticker, pendingUnpinnedAllMessages: false, activeGroupCallInfo: nil, hasActiveGroupCall: false, importState: nil, threadData: nil, isGeneralThreadClosed: nil)
|
||||
self.presentationInterfaceState = ChatPresentationInterfaceState(chatWallpaper: self.presentationData.chatWallpaper, theme: self.presentationData.theme, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameDisplayOrder: self.presentationData.nameDisplayOrder, limitsConfiguration: context.currentLimitsConfiguration.with { $0 }, fontSize: self.presentationData.chatFontSize, bubbleCorners: self.presentationData.chatBubbleCorners, accountPeerId: context.account.peerId, mode: mode, chatLocation: chatLocation, subject: subject, peerNearbyData: peerNearbyData, greetingData: context.prefetchManager?.preloadedGreetingSticker, pendingUnpinnedAllMessages: false, activeGroupCallInfo: nil, hasActiveGroupCall: false, importState: nil, threadData: nil, isGeneralThreadClosed: nil, replyMessage: nil)
|
||||
self.presentationInterfaceStatePromise = ValuePromise(self.presentationInterfaceState)
|
||||
|
||||
var mediaAccessoryPanelVisibility = MediaAccessoryPanelVisibility.none
|
||||
@@ -6764,6 +6765,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
self.urlPreviewQueryState?.1.dispose()
|
||||
self.editingUrlPreviewQueryState?.1.dispose()
|
||||
self.replyMessageState?.1.dispose()
|
||||
self.audioRecorderDisposable?.dispose()
|
||||
self.audioRecorderStatusDisposable?.dispose()
|
||||
self.videoRecorderDisposable?.dispose()
|
||||
@@ -8040,7 +8042,17 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
strongSelf.updateItemNodesHighlightedStates(animated: initial)
|
||||
strongSelf.scrolledToMessageIdValue = ScrolledToMessageId(id: index.id, allowedReplacementDirection: [])
|
||||
|
||||
strongSelf.messageContextDisposable.set((Signal<Void, NoError>.complete() |> delay(0.7, queue: Queue.mainQueue())).startStrict(completed: {
|
||||
var hasQuote = false
|
||||
if let quote = toSubject.quote {
|
||||
if message.text.contains(quote) {
|
||||
hasQuote = true
|
||||
} else {
|
||||
//TODO:localize
|
||||
strongSelf.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .info(title: nil, text: "Quote not found", timeout: nil), elevatedLayout: false, action: { _ in return true }), in: .current)
|
||||
}
|
||||
}
|
||||
|
||||
strongSelf.messageContextDisposable.set((Signal<Void, NoError>.complete() |> delay(hasQuote ? 1.5 : 0.7, queue: Queue.mainQueue())).startStrict(completed: {
|
||||
if let strongSelf = self, let controllerInteraction = strongSelf.controllerInteraction {
|
||||
if controllerInteraction.highlightedState == highlightedState {
|
||||
controllerInteraction.highlightedState = nil
|
||||
@@ -8049,11 +8061,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
}))
|
||||
|
||||
if let quote = toSubject.quote, !message.text.contains(quote) {
|
||||
//TODO:localize
|
||||
strongSelf.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .info(title: nil, text: "Quote not found", timeout: nil), elevatedLayout: false, action: { _ in return true }), in: .current)
|
||||
}
|
||||
|
||||
if let (messageId, params) = strongSelf.scheduledScrollToMessageId {
|
||||
strongSelf.scheduledScrollToMessageId = nil
|
||||
if let timecode = params.timestamp, message.id == messageId {
|
||||
@@ -12381,6 +12388,32 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
}
|
||||
|
||||
if let replyMessageId = updatedChatPresentationInterfaceState.interfaceState.replyMessageSubject?.messageId {
|
||||
if self.replyMessageState?.0 != replyMessageId {
|
||||
self.replyMessageState?.1.dispose()
|
||||
updatedChatPresentationInterfaceState = updatedChatPresentationInterfaceState.updatedReplyMessage(nil)
|
||||
let disposable = MetaDisposable()
|
||||
self.replyMessageState = (replyMessageId, disposable)
|
||||
disposable.set((self.context.engine.data.subscribe(TelegramEngine.EngineData.Item.Messages.Message(id: replyMessageId))
|
||||
|> deliverOnMainQueue).start(next: { [weak self] message in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
if message != self.presentationInterfaceState.replyMessage.flatMap(EngineMessage.init) {
|
||||
self.updateChatPresentationInterfaceState(interactive: false, { presentationInterfaceState in
|
||||
return presentationInterfaceState.updatedReplyMessage(message?._asMessage())
|
||||
})
|
||||
}
|
||||
}))
|
||||
}
|
||||
} else {
|
||||
if let replyMessageState = self.replyMessageState {
|
||||
self.replyMessageState = nil
|
||||
replyMessageState.1.dispose()
|
||||
updatedChatPresentationInterfaceState = updatedChatPresentationInterfaceState.updatedReplyMessage(nil)
|
||||
}
|
||||
}
|
||||
|
||||
if let updated = self.updateSearch(updatedChatPresentationInterfaceState) {
|
||||
updatedChatPresentationInterfaceState = updated
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user