[WIP] Topics

This commit is contained in:
Ali
2022-10-22 01:54:19 +04:00
parent c712049972
commit eb5fa016e0
2 changed files with 23 additions and 5 deletions

View File

@@ -500,10 +500,24 @@ func _internal_loadMessageHistoryThreads(accountPeerId: PeerId, postbox: Postbox
transaction.replaceMessageTagSummary(peerId: peerId, threadId: Int64(id), tagMask: .unseenPersonalMessage, namespace: Namespaces.Message.Cloud, count: unreadMentionsCount, maxId: topMessage)
transaction.replaceMessageTagSummary(peerId: peerId, threadId: Int64(id), tagMask: .unseenReaction, namespace: Namespaces.Message.Cloud, count: unreadReactionsCount, maxId: topMessage)
if topMessage != 0 {
transaction.removeHole(peerId: peerId, threadId: Int64(id), namespace: Namespaces.Message.Cloud, space: .everywhere, range: topMessage ... (Int32.max - 1))
}
var topTimestamp = date
for message in addedMessages {
if message.id.peerId == peerId && message.threadId == Int64(id) {
topTimestamp = max(topTimestamp, message.timestamp)
if case let .Id(messageId) = message.id {
for media in message.media {
if let action = media as? TelegramMediaAction {
if case .topicCreated = action.action {
transaction.removeHole(peerId: messageId.peerId, threadId: Int64(id), namespace: Namespaces.Message.Cloud, space: .everywhere, range: 1 ... messageId.id)
}
}
}
}
}
}
@@ -520,11 +534,13 @@ func _internal_loadMessageHistoryThreads(accountPeerId: PeerId, postbox: Postbox
}
}
if offsetIndex != nil {
if let pinnedId = pinnedId {
transaction.setPeerPinnedThreads(peerId: peerId, threadIds: [pinnedId])
} else {
transaction.setPeerPinnedThreads(peerId: peerId, threadIds: [])
}
}
var nextIndex: StoredPeerThreadCombinedState.Index
if topics.count != 0 {

View File

@@ -3027,6 +3027,8 @@ func replayFinalState(
for media in message.media {
if let action = media as? TelegramMediaAction {
switch action.action {
case .topicCreated:
transaction.removeHole(peerId: id.peerId, threadId: threadId, namespace: Namespaces.Message.Cloud, space: .everywhere, range: 1 ... id.id)
case let .topicEdited(components):
if let initialData = transaction.getMessageHistoryThreadInfo(peerId: id.peerId, threadId: threadId)?.data.get(MessageHistoryThreadData.self) {
var data = initialData
@@ -3038,7 +3040,7 @@ func replayFinalState(
case let .iconFileId(fileId):
data.info = EngineMessageHistoryThread.Info(title: data.info.title, icon: fileId == 0 ? nil : fileId, iconColor: data.info.iconColor)
case let .isClosed(isClosed):
let _ = isClosed
data.isClosed = isClosed
}
}