- Forum improvements

- Global autoremove settings
This commit is contained in:
Ali
2022-11-25 23:08:40 +04:00
parent b358391e1d
commit 1656ecff49
82 changed files with 2495 additions and 1059 deletions

View File

@@ -515,7 +515,7 @@ private final class ChatListViewSpaceState {
let entryPeer: Peer
let entryNotificationsPeerId: PeerId
switch entry {
case let .MessageEntry(_, _, _, _, _, _, renderedPeer, _, _, _, _, _, _):
case let .MessageEntry(_, _, _, _, _, _, renderedPeer, _, _, _, _, _, _, _):
if let peer = renderedPeer.peer {
entryPeer = peer
entryNotificationsPeerId = peer.notificationSettingsPeerId ?? peer.id
@@ -630,13 +630,13 @@ private final class ChatListViewSpaceState {
if self.orderedEntries.mutableScan({ entry in
switch entry {
case let .MessageEntry(index, messages, readState, _, _, embeddedInterfaceState, renderedPeer, presence, tagSummaryInfo, forumTopicData, topForumTopics, hasFailedMessages, isContact):
case let .MessageEntry(index, messages, readState, _, _, embeddedInterfaceState, renderedPeer, presence, tagSummaryInfo, forumTopicData, topForumTopics, hasFailedMessages, isContact, autoremoveTimeout):
if let peer = renderedPeer.peer {
let notificationsPeerId = peer.notificationSettingsPeerId ?? peer.id
if let (_, updated) = transaction.currentUpdatedPeerNotificationSettings[notificationsPeerId] {
let isRemovedFromTotalUnreadCount = resolvedIsRemovedFromTotalUnreadCount(globalSettings: globalNotificationSettings, peer: peer, peerSettings: updated)
return .MessageEntry(index: index, messages: messages, readState: readState, notificationSettings: updated, isRemovedFromTotalUnreadCount: isRemovedFromTotalUnreadCount, embeddedInterfaceState: embeddedInterfaceState, renderedPeer: renderedPeer, presence: presence, tagSummaryInfo: tagSummaryInfo, forumTopicData: forumTopicData, topForumTopics: topForumTopics, hasFailedMessages: hasFailedMessages, isContact: isContact)
return .MessageEntry(index: index, messages: messages, readState: readState, notificationSettings: updated, isRemovedFromTotalUnreadCount: isRemovedFromTotalUnreadCount, embeddedInterfaceState: embeddedInterfaceState, renderedPeer: renderedPeer, presence: presence, tagSummaryInfo: tagSummaryInfo, forumTopicData: forumTopicData, topForumTopics: topForumTopics, hasFailedMessages: hasFailedMessages, isContact: isContact, autoremoveTimeout: autoremoveTimeout)
} else {
return nil
}
@@ -654,7 +654,7 @@ private final class ChatListViewSpaceState {
if !transaction.updatedFailedMessagePeerIds.isEmpty {
if self.orderedEntries.mutableScan({ entry in
switch entry {
case let .MessageEntry(index, messages, readState, notificationSettings, isRemovedFromTotalUnreadCount, embeddedInterfaceState, renderedPeer, presence, tagSummaryInfo, forumTopicData, topForumTopics, _, isContact):
case let .MessageEntry(index, messages, readState, notificationSettings, isRemovedFromTotalUnreadCount, embeddedInterfaceState, renderedPeer, presence, tagSummaryInfo, forumTopicData, topForumTopics, _, isContact, autoremoveTimeout):
if transaction.updatedFailedMessagePeerIds.contains(index.messageIndex.id.peerId) {
return .MessageEntry(
index: index,
@@ -669,7 +669,8 @@ private final class ChatListViewSpaceState {
forumTopicData: forumTopicData,
topForumTopics: topForumTopics,
hasFailedMessages: postbox.messageHistoryFailedTable.contains(peerId: index.messageIndex.id.peerId),
isContact: isContact
isContact: isContact,
autoremoveTimeout: autoremoveTimeout
)
} else {
return nil
@@ -685,7 +686,7 @@ private final class ChatListViewSpaceState {
if !transaction.currentUpdatedPeers.isEmpty {
if self.orderedEntries.mutableScan({ entry in
switch entry {
case let .MessageEntry(index, messages, readState, notificationSettings, isRemovedFromTotalUnreadCount, embeddedInterfaceState, entryRenderedPeer, presence, tagSummaryInfo, forumTopicData, topForumTopics, hasFailedMessages, isContact):
case let .MessageEntry(index, messages, readState, notificationSettings, isRemovedFromTotalUnreadCount, embeddedInterfaceState, entryRenderedPeer, presence, tagSummaryInfo, forumTopicData, topForumTopics, hasFailedMessages, isContact, autoremoveTimeout):
var updatedMessages: [Message] = messages
var hasUpdatedMessages = false
for i in 0 ..< updatedMessages.count {
@@ -710,7 +711,9 @@ private final class ChatListViewSpaceState {
forumTopicData: forumTopicData,
topForumTopics: topForumTopics,
hasFailedMessages: hasFailedMessages,
isContact: isContact)
isContact: isContact,
autoremoveTimeout: autoremoveTimeout
)
} else {
return nil
}
@@ -725,7 +728,7 @@ private final class ChatListViewSpaceState {
if !transaction.currentUpdatedPeerPresences.isEmpty {
if self.orderedEntries.mutableScan({ entry in
switch entry {
case let .MessageEntry(index, messages, readState, notificationSettings, isRemovedFromTotalUnreadCount, embeddedInterfaceState, entryRenderedPeer, _, tagSummaryInfo, forumTopicData, topForumTopics, hasFailedMessages, isContact):
case let .MessageEntry(index, messages, readState, notificationSettings, isRemovedFromTotalUnreadCount, embeddedInterfaceState, entryRenderedPeer, _, tagSummaryInfo, forumTopicData, topForumTopics, hasFailedMessages, isContact, autoremoveTimeout):
var presencePeerId = entryRenderedPeer.peerId
if let peer = entryRenderedPeer.peers[entryRenderedPeer.peerId], let associatedPeerId = peer.associatedPeerId {
presencePeerId = associatedPeerId
@@ -744,7 +747,8 @@ private final class ChatListViewSpaceState {
forumTopicData: forumTopicData,
topForumTopics: topForumTopics,
hasFailedMessages: hasFailedMessages,
isContact: isContact
isContact: isContact,
autoremoveTimeout: autoremoveTimeout
)
} else {
return nil
@@ -763,7 +767,7 @@ private final class ChatListViewSpaceState {
let entryPeer: Peer
let entryNotificationsPeerId: PeerId
switch entry {
case let .MessageEntry(_, _, _, _, _, _, entryRenderedPeer, _, _, _, _, _, _):
case let .MessageEntry(_, _, _, _, _, _, entryRenderedPeer, _, _, _, _, _, _, _):
if let peer = entryRenderedPeer.peer {
entryPeer = peer
entryNotificationsPeerId = peer.notificationSettingsPeerId ?? peer.id
@@ -881,10 +885,20 @@ private final class ChatListViewSpaceState {
}
}
if !transaction.currentUpdatedMessageTagSummaries.isEmpty || !transaction.currentUpdatedMessageActionsSummaries.isEmpty || !transaction.updatedPeerThreadsSummaries.isEmpty {
var cachedPeerDataUpdated = false
if !transaction.currentUpdatedCachedPeerData.isEmpty {
let _ = self.orderedEntries.mutableScan { entry in
if transaction.currentUpdatedCachedPeerData[entry.index.messageIndex.id.peerId] != nil {
cachedPeerDataUpdated = true
}
return nil
}
}
if !transaction.currentUpdatedMessageTagSummaries.isEmpty || !transaction.currentUpdatedMessageActionsSummaries.isEmpty || !transaction.updatedPeerThreadsSummaries.isEmpty || cachedPeerDataUpdated {
if self.orderedEntries.mutableScan({ entry in
switch entry {
case let .MessageEntry(index, messages, readState, notificationSettings, isRemovedFromTotalUnreadCount, embeddedInterfaceState, entryRenderedPeer, presence, tagSummaryInfo, forumTopicData, topForumTopics, hasFailedMessages, isContact):
case let .MessageEntry(index, messages, readState, notificationSettings, isRemovedFromTotalUnreadCount, embeddedInterfaceState, entryRenderedPeer, presence, tagSummaryInfo, forumTopicData, topForumTopics, hasFailedMessages, isContact, autoremoveTimeout):
var updatedChatListMessageTagSummaryInfo: [ChatListEntryMessageTagSummaryKey: ChatListMessageTagSummaryInfo] = tagSummaryInfo
var didUpdateSummaryInfo = false
@@ -938,6 +952,14 @@ private final class ChatListViewSpaceState {
didUpdateSummaryInfo = true
}
var updatedAutoremoveTimeout: Int32?
if let cachedData = postbox.cachedPeerDataTable.get(index.messageIndex.id.peerId) {
updatedAutoremoveTimeout = postbox.seedConfiguration.decodeAutoremoveTimeout(cachedData)
if updatedAutoremoveTimeout != autoremoveTimeout {
didUpdateSummaryInfo = true
}
}
if didUpdateSummaryInfo {
return .MessageEntry(
index: index,
@@ -952,7 +974,8 @@ private final class ChatListViewSpaceState {
forumTopicData: forumTopicData,
topForumTopics: topForumTopics,
hasFailedMessages: hasFailedMessages,
isContact: isContact
isContact: isContact,
autoremoveTimeout: updatedAutoremoveTimeout
)
} else {
return nil
@@ -1086,7 +1109,7 @@ private extension MutableChatListEntry {
switch self {
case let .IntermediateMessageEntry(index, _):
return index.messageIndex.id.peerId
case let .MessageEntry(index, _, _, _, _, _, _, _, _, _, _, _, _):
case let .MessageEntry(index, _, _, _, _, _, _, _, _, _, _, _, _, _):
return index.messageIndex.id.peerId
case .HoleEntry:
return nil
@@ -1097,7 +1120,7 @@ private extension MutableChatListEntry {
switch self {
case let .IntermediateMessageEntry(index, _):
return MutableChatListEntryIndex(index: index, isMessage: true)
case let .MessageEntry(index, _, _, _, _, _, _, _, _, _, _, _, _):
case let .MessageEntry(index, _, _, _, _, _, _, _, _, _, _, _, _, _):
return MutableChatListEntryIndex(index: index, isMessage: true)
case let .HoleEntry(hole):
return MutableChatListEntryIndex(index: ChatListIndex(pinningIndex: nil, messageIndex: hole.index), isMessage: false)
@@ -1108,7 +1131,7 @@ private extension MutableChatListEntry {
switch self {
case let .IntermediateMessageEntry(index, _):
return .peer(index.messageIndex.id.peerId)
case let .MessageEntry(index, _, _, _, _, _, _, _, _, _, _, _, _):
case let .MessageEntry(index, _, _, _, _, _, _, _, _, _, _, _, _, _):
return .peer(index.messageIndex.id.peerId)
case let .HoleEntry(hole):
return .hole(hole.index)
@@ -1558,7 +1581,12 @@ struct ChatListViewState {
}
}
let updatedEntry: MutableChatListEntry = .MessageEntry(index: index, messages: renderedMessages, readState: readState, notificationSettings: notificationSettings, isRemovedFromTotalUnreadCount: isRemovedFromTotalUnreadCount, embeddedInterfaceState: postbox.peerChatInterfaceStateTable.get(index.messageIndex.id.peerId), renderedPeer: renderedPeer, presence: presence, tagSummaryInfo: tagSummaryInfo, forumTopicData: forumTopicData, topForumTopics: topForumTopics, hasFailedMessages: false, isContact: postbox.contactsTable.isContact(peerId: index.messageIndex.id.peerId))
var autoremoveTimeout: Int32?
if let cachedData = postbox.cachedPeerDataTable.get(index.messageIndex.id.peerId) {
autoremoveTimeout = postbox.seedConfiguration.decodeAutoremoveTimeout(cachedData)
}
let updatedEntry: MutableChatListEntry = .MessageEntry(index: index, messages: renderedMessages, readState: readState, notificationSettings: notificationSettings, isRemovedFromTotalUnreadCount: isRemovedFromTotalUnreadCount, embeddedInterfaceState: postbox.peerChatInterfaceStateTable.get(index.messageIndex.id.peerId), renderedPeer: renderedPeer, presence: presence, tagSummaryInfo: tagSummaryInfo, forumTopicData: forumTopicData, topForumTopics: topForumTopics, hasFailedMessages: false, isContact: postbox.contactsTable.isContact(peerId: index.messageIndex.id.peerId), autoremoveTimeout: autoremoveTimeout)
if directionIndex == 0 {
self.stateBySpace[space]!.orderedEntries.setLowerOrAtAnchorAtArrayIndex(listIndex, to: updatedEntry)
} else {