Another feed experiment

This commit is contained in:
Ali
2022-03-18 22:55:06 +04:00
parent fe0311b1e9
commit a9c595a640
128 changed files with 3524 additions and 957 deletions

View File

@@ -928,7 +928,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
let customChannelDiscussionReadState: Signal<MessageId?, NoError>
if case let .peer(peerId) = chatLocation, peerId.namespace == Namespaces.Peer.CloudChannel {
let cachedDataKey = PostboxViewKey.cachedPeerData(peerId: chatLocation.peerId)
let cachedDataKey = PostboxViewKey.cachedPeerData(peerId: peerId)
let peerKey = PostboxViewKey.basicPeer(peerId)
customChannelDiscussionReadState = context.account.postbox.combinedView(keys: [cachedDataKey, peerKey])
|> mapToSignal { views -> Signal<PeerId?, NoError> in
@@ -1062,7 +1062,12 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
case let .id(id):
initialSearchLocation = .id(id)
case let .timestamp(timestamp):
initialSearchLocation = .index(MessageIndex(id: MessageId(peerId: strongSelf.chatLocation.peerId, namespace: Namespaces.Message.Cloud, id: 1), timestamp: timestamp))
if let peerId = strongSelf.chatLocation.peerId {
initialSearchLocation = .index(MessageIndex(id: MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: 1), timestamp: timestamp))
} else {
//TODO:implement
initialSearchLocation = .index(.absoluteUpperBound())
}
}
strongSelf.chatHistoryLocationValue = ChatHistoryLocationInput(content: .InitialSearch(location: initialSearchLocation, count: 60, highlight: highlight), id: (strongSelf.chatHistoryLocationValue?.id).flatMap({ $0 + 1 }) ?? 0)
} else if let subject = subject, case let .pinnedMessages(maybeMessageId) = subject, let messageId = maybeMessageId {
@@ -1307,7 +1312,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
}
if apply {
switch chatLocation {
case .peer, .replyThread:
case .peer, .replyThread, .feed:
if !context.sharedContext.immediateExperimentalUISettings.skipReadHistory {
context.applyMaxReadIndex(for: chatLocation, contextHolder: chatLocationContextHolder, messageIndex: messageIndex)
}
@@ -1348,7 +1353,12 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
case let .id(id):
initialSearchLocation = .id(id)
case let .timestamp(timestamp):
initialSearchLocation = .index(MessageIndex(id: MessageId(peerId: self.chatLocation.peerId, namespace: Namespaces.Message.Cloud, id: 1), timestamp: timestamp))
if let peerId = self.chatLocation.peerId {
initialSearchLocation = .index(MessageIndex(id: MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: 1), timestamp: timestamp))
} else {
//TODO:implement
initialSearchLocation = .index(MessageIndex.absoluteUpperBound())
}
}
self.chatHistoryLocationValue = ChatHistoryLocationInput(content: .InitialSearch(location: initialSearchLocation, count: 60, highlight: highlight), id: 0)
} else if let subject = subject, case let .pinnedMessages(maybeMessageId) = subject, let messageId = maybeMessageId {
@@ -2108,7 +2118,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
switch self.chatLocation {
case .peer:
messageIndex = maxIncomingIndex
case .replyThread:
case .replyThread, .feed:
messageIndex = maxOverallIndex
}
@@ -2520,7 +2530,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
switch strongSelf.chatLocation {
case .peer:
messageIndex = incomingIndex
case .replyThread:
case .replyThread, .feed:
messageIndex = overallIndex
}