mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
- Story search UI
- Delete message confirmation
This commit is contained in:
@@ -83,6 +83,7 @@ struct ChatHistoryView {
|
||||
let id: Int32
|
||||
let locationInput: ChatHistoryLocationInput?
|
||||
let ignoreMessagesInTimestampRange: ClosedRange<Int32>?
|
||||
let ignoreMessageIds: Set<MessageId>
|
||||
}
|
||||
|
||||
enum ChatHistoryViewTransitionReason {
|
||||
@@ -536,6 +537,15 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
}
|
||||
}
|
||||
|
||||
private let ignoreMessageIdsPromise = ValuePromise<Set<EngineMessage.Id>>(Set())
|
||||
var ignoreMessageIds: Set<EngineMessage.Id> = Set() {
|
||||
didSet {
|
||||
if self.ignoreMessageIds != oldValue {
|
||||
self.ignoreMessageIdsPromise.set(self.ignoreMessageIds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private let chatHasBotsPromise = ValuePromise<Bool>(false)
|
||||
var chatHasBots: Bool = false {
|
||||
didSet {
|
||||
@@ -1263,7 +1273,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
|
||||
let currentViewVersion = self.currentViewVersion
|
||||
|
||||
let historyViewUpdate: Signal<(ChatHistoryViewUpdate, Int, ChatHistoryLocationInput?, ClosedRange<Int32>?), NoError>
|
||||
let historyViewUpdate: Signal<(ChatHistoryViewUpdate, Int, ChatHistoryLocationInput?, ClosedRange<Int32>?, Set<MessageId>), NoError>
|
||||
var isFirstTime = true
|
||||
var updateAllOnEachVersion = false
|
||||
if case let .custom(messages, at, quote, _) = self.source {
|
||||
@@ -1286,12 +1296,13 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
scrollPosition = nil
|
||||
}
|
||||
|
||||
return (ChatHistoryViewUpdate.HistoryView(view: MessageHistoryView(tag: nil, namespaces: .all, entries: messages.reversed().map { MessageHistoryEntry(message: $0, isRead: false, location: nil, monthLocation: nil, attributes: MutableMessageHistoryEntryAttributes(authorIsContact: false)) }, holeEarlier: hasMore, holeLater: false, isLoading: false), type: .Generic(type: version > 0 ? ViewUpdateType.Generic : ViewUpdateType.Initial), scrollPosition: scrollPosition, flashIndicators: false, originalScrollPosition: nil, initialData: ChatHistoryCombinedInitialData(initialData: nil, buttonKeyboardMessage: nil, cachedData: nil, cachedDataMessages: nil, readStateData: nil), id: 0), version, nil, nil)
|
||||
return (ChatHistoryViewUpdate.HistoryView(view: MessageHistoryView(tag: nil, namespaces: .all, entries: messages.reversed().map { MessageHistoryEntry(message: $0, isRead: false, location: nil, monthLocation: nil, attributes: MutableMessageHistoryEntryAttributes(authorIsContact: false)) }, holeEarlier: hasMore, holeLater: false, isLoading: false), type: .Generic(type: version > 0 ? ViewUpdateType.Generic : ViewUpdateType.Initial), scrollPosition: scrollPosition, flashIndicators: false, originalScrollPosition: nil, initialData: ChatHistoryCombinedInitialData(initialData: nil, buttonKeyboardMessage: nil, cachedData: nil, cachedDataMessages: nil, readStateData: nil), id: 0), version, nil, nil, Set())
|
||||
}
|
||||
} else if case let .customView(historyView) = self.source {
|
||||
historyViewUpdate = combineLatest(queue: .mainQueue(),
|
||||
self.chatHistoryLocationPromise.get(),
|
||||
self.ignoreMessagesInTimestampRangePromise.get()
|
||||
self.ignoreMessagesInTimestampRangePromise.get(),
|
||||
self.ignoreMessageIdsPromise.get()
|
||||
)
|
||||
|> distinctUntilChanged(isEqual: { lhs, rhs in
|
||||
if lhs.0 != rhs.0 {
|
||||
@@ -1300,9 +1311,12 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
if lhs.1 != rhs.1 {
|
||||
return false
|
||||
}
|
||||
if lhs.2 != rhs.2 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
|> mapToSignal { location, _ -> Signal<((MessageHistoryView, ViewUpdateType), ChatHistoryLocationInput?), NoError> in
|
||||
|> mapToSignal { location, _, _ -> Signal<((MessageHistoryView, ViewUpdateType), ChatHistoryLocationInput?), NoError> in
|
||||
return historyView
|
||||
|> map { historyView in
|
||||
return (historyView, location)
|
||||
@@ -1347,13 +1361,15 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
),
|
||||
version,
|
||||
location,
|
||||
nil
|
||||
nil,
|
||||
Set()
|
||||
)
|
||||
}
|
||||
} else {
|
||||
historyViewUpdate = combineLatest(queue: .mainQueue(),
|
||||
self.chatHistoryLocationPromise.get(),
|
||||
self.ignoreMessagesInTimestampRangePromise.get()
|
||||
self.ignoreMessagesInTimestampRangePromise.get(),
|
||||
self.ignoreMessageIdsPromise.get()
|
||||
)
|
||||
|> distinctUntilChanged(isEqual: { lhs, rhs in
|
||||
if lhs.0 != rhs.0 {
|
||||
@@ -1362,10 +1378,13 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
if lhs.1 != rhs.1 {
|
||||
return false
|
||||
}
|
||||
if lhs.2 != rhs.2 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
|> mapToSignal { location, ignoreMessagesInTimestampRange in
|
||||
return chatHistoryViewForLocation(location, ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange, context: context, chatLocation: chatLocation, chatLocationContextHolder: chatLocationContextHolder, scheduled: isScheduledMessages, fixedCombinedReadStates: fixedCombinedReadStates.with { $0 }, tag: tag, appendMessagesFromTheSameGroup: appendMessagesFromTheSameGroup, additionalData: additionalData, orderStatistics: [], useRootInterfaceStateForThread: useRootInterfaceStateForThread)
|
||||
|> mapToSignal { location, ignoreMessagesInTimestampRange, ignoreMessageIds in
|
||||
return chatHistoryViewForLocation(location, ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange, ignoreMessageIds: ignoreMessageIds, context: context, chatLocation: chatLocation, chatLocationContextHolder: chatLocationContextHolder, scheduled: isScheduledMessages, fixedCombinedReadStates: fixedCombinedReadStates.with { $0 }, tag: tag, appendMessagesFromTheSameGroup: appendMessagesFromTheSameGroup, additionalData: additionalData, orderStatistics: [], useRootInterfaceStateForThread: useRootInterfaceStateForThread)
|
||||
|> beforeNext { viewUpdate in
|
||||
switch viewUpdate {
|
||||
case let .HistoryView(view, _, _, _, _, _, _):
|
||||
@@ -1374,7 +1393,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
break
|
||||
}
|
||||
}
|
||||
|> map { view -> (ChatHistoryViewUpdate, Int, ChatHistoryLocationInput?, ClosedRange<Int32>?) in
|
||||
|> map { view -> (ChatHistoryViewUpdate, Int, ChatHistoryLocationInput?, ClosedRange<Int32>?, Set<MessageId>) in
|
||||
let version = currentViewVersion.modify({ value in
|
||||
if let value = value {
|
||||
return value + 1
|
||||
@@ -1382,7 +1401,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
return 0
|
||||
}
|
||||
})!
|
||||
return (view, version, location, ignoreMessagesInTimestampRange)
|
||||
return (view, version, location, ignoreMessagesInTimestampRange, ignoreMessageIds)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1675,7 +1694,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
|
||||
if resetScrolling, let previousViewValue = previousView.with({ $0 })?.0 {
|
||||
let filteredEntries: [ChatHistoryEntry] = []
|
||||
let processedView = ChatHistoryView(originalView: MessageHistoryView(tag: nil, namespaces: .all, entries: [], holeEarlier: false, holeLater: false, isLoading: true), filteredEntries: filteredEntries, associatedData: previousViewValue.associatedData, lastHeaderId: 0, id: previousViewValue.id, locationInput: previousViewValue.locationInput, ignoreMessagesInTimestampRange: nil)
|
||||
let processedView = ChatHistoryView(originalView: MessageHistoryView(tag: nil, namespaces: .all, entries: [], holeEarlier: false, holeLater: false, isLoading: true), filteredEntries: filteredEntries, associatedData: previousViewValue.associatedData, lastHeaderId: 0, id: previousViewValue.id, locationInput: previousViewValue.locationInput, ignoreMessagesInTimestampRange: nil, ignoreMessageIds: Set())
|
||||
let previousValueAndVersion = previousView.swap((processedView, update.1, selectedMessages, allAdMessages.version))
|
||||
let previous = previousValueAndVersion?.0
|
||||
let previousSelectedMessages = previousValueAndVersion?.2
|
||||
@@ -1847,7 +1866,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
dynamicAdMessages: allAdMessages.opportunistic
|
||||
)
|
||||
let lastHeaderId = filteredEntries.last.flatMap { listMessageDateHeaderId(timestamp: $0.index.timestamp) } ?? 0
|
||||
let processedView = ChatHistoryView(originalView: view, filteredEntries: filteredEntries, associatedData: associatedData, lastHeaderId: lastHeaderId, id: id, locationInput: update.2, ignoreMessagesInTimestampRange: update.3)
|
||||
let processedView = ChatHistoryView(originalView: view, filteredEntries: filteredEntries, associatedData: associatedData, lastHeaderId: lastHeaderId, id: id, locationInput: update.2, ignoreMessagesInTimestampRange: update.3, ignoreMessageIds: update.4)
|
||||
let previousValueAndVersion = previousView.swap((processedView, update.1, selectedMessages, allAdMessages.version))
|
||||
let previous = previousValueAndVersion?.0
|
||||
let previousSelectedMessages = previousValueAndVersion?.2
|
||||
@@ -1877,6 +1896,9 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
} else if let previous = previous, previous.id == processedView.id, previous.originalView.entries == processedView.originalView.entries {
|
||||
reason = ChatHistoryViewTransitionReason.InteractiveChanges
|
||||
updatedScrollPosition = nil
|
||||
} else if let previous = previous, previous.id == processedView.id, previous.ignoreMessageIds != processedView.ignoreMessageIds {
|
||||
reason = ChatHistoryViewTransitionReason.InteractiveChanges
|
||||
updatedScrollPosition = nil
|
||||
} else {
|
||||
switch type {
|
||||
case let .Initial(fadeIn):
|
||||
@@ -3423,6 +3445,14 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
}
|
||||
}
|
||||
}
|
||||
for id in self.ignoreMessageIds {
|
||||
inner: for (stableId, listId) in maybeRemovedInteractivelyMessageIds {
|
||||
if listId == id {
|
||||
expiredMessageStableIds.insert(stableId)
|
||||
break inner
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.currentDeleteAnimationCorrelationIds.formUnion(expiredMessageStableIds)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user