mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 11:23:48 +00:00
Fix unread navigation
This commit is contained in:
parent
845039f5e8
commit
ebc8acec6a
@ -1527,7 +1527,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
let contentImageSpacing: CGFloat = 2.0
|
||||
let contentImageTrailingSpace: CGFloat = 5.0
|
||||
var contentImageSpecs: [(message: EngineMessage, media: EngineMedia, size: CGSize)] = []
|
||||
var forumThread: (id: Int64, title: String, iconId: Int64?, iconColor: Int32)?
|
||||
var forumThread: (id: Int64, title: String, iconId: Int64?, iconColor: Int32, isUnread: Bool)?
|
||||
|
||||
switch contentData {
|
||||
case let .chat(itemPeer, _, _, _, text, spoilers, customEmojiRanges):
|
||||
@ -1555,9 +1555,9 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
|
||||
if let _ = peerText, case let .channel(channel) = itemPeer.chatMainPeer, channel.flags.contains(.isForum), threadInfo == nil {
|
||||
if let forumTopicData = forumTopicData {
|
||||
forumThread = (forumTopicData.id, forumTopicData.title, forumTopicData.iconFileId, forumTopicData.iconColor)
|
||||
forumThread = (forumTopicData.id, forumTopicData.title, forumTopicData.iconFileId, forumTopicData.iconColor, forumTopicData.isUnread)
|
||||
} else if let threadInfo = threadInfo {
|
||||
forumThread = (threadInfo.id, threadInfo.info.title, threadInfo.info.icon, threadInfo.info.iconColor)
|
||||
forumThread = (threadInfo.id, threadInfo.info.title, threadInfo.info.icon, threadInfo.info.iconColor, false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -2021,11 +2021,11 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
var forumThreads: [(id: Int64, title: NSAttributedString, iconId: Int64?, iconColor: Int32)] = []
|
||||
if forumThread != nil || !topForumTopicItems.isEmpty {
|
||||
if let forumThread = forumThread {
|
||||
forumThreads.append((id: forumThread.id, title: NSAttributedString(string: forumThread.title, font: textFont, textColor: theme.authorNameColor), iconId: forumThread.iconId, iconColor: forumThread.iconColor))
|
||||
forumThreads.append((id: forumThread.id, title: NSAttributedString(string: forumThread.title, font: textFont, textColor: forumThread.isUnread ? theme.authorNameColor : theme.messageTextColor), iconId: forumThread.iconId, iconColor: forumThread.iconColor))
|
||||
}
|
||||
for item in topForumTopicItems {
|
||||
if forumThread?.id != item.id {
|
||||
forumThreads.append((id: item.id, title: NSAttributedString(string: item.title, font: textFont, textColor: theme.authorNameColor), iconId: item.iconFileId, iconColor: item.iconColor))
|
||||
forumThreads.append((id: item.id, title: NSAttributedString(string: item.title, font: textFont, textColor: item.isUnread ? theme.authorNameColor : theme.messageTextColor), iconId: item.iconFileId, iconColor: item.iconColor))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3187,7 +3187,7 @@ func replayFinalState(
|
||||
|
||||
if message.flags.contains(.Incoming) {
|
||||
if var data = transaction.getMessageHistoryThreadInfo(peerId: id.peerId, threadId: threadId)?.data.get(MessageHistoryThreadData.self) {
|
||||
if id.id >= data.maxKnownMessageId {
|
||||
if data.maxIncomingReadId != 0 && id.id >= data.maxKnownMessageId {
|
||||
data.maxKnownMessageId = id.id
|
||||
data.incomingUnreadCount += 1
|
||||
|
||||
@ -3464,6 +3464,7 @@ func replayFinalState(
|
||||
}
|
||||
|
||||
data.maxKnownMessageId = max(data.maxKnownMessageId, readMaxId)
|
||||
data.maxIncomingReadId = max(data.maxIncomingReadId, readMaxId)
|
||||
|
||||
if let entry = StoredMessageHistoryThreadInfo(data) {
|
||||
transaction.setMessageHistoryThreadInfo(peerId: threadMessageId.peerId, threadId: Int64(threadMessageId.id), info: entry)
|
||||
|
@ -30,16 +30,18 @@ public final class EngineChatList: Equatable {
|
||||
public struct ForumTopicData: Equatable {
|
||||
public var id: Int64
|
||||
public var title: String
|
||||
public let iconFileId: Int64?
|
||||
public let iconColor: Int32
|
||||
public var iconFileId: Int64?
|
||||
public var iconColor: Int32
|
||||
public var maxOutgoingReadMessageId: EngineMessage.Id
|
||||
public var isUnread: Bool
|
||||
|
||||
public init(id: Int64, title: String, iconFileId: Int64?, iconColor: Int32, maxOutgoingReadMessageId: EngineMessage.Id) {
|
||||
public init(id: Int64, title: String, iconFileId: Int64?, iconColor: Int32, maxOutgoingReadMessageId: EngineMessage.Id, isUnread: Bool) {
|
||||
self.id = id
|
||||
self.title = title
|
||||
self.iconFileId = iconFileId
|
||||
self.iconColor = iconColor
|
||||
self.maxOutgoingReadMessageId = maxOutgoingReadMessageId
|
||||
self.isUnread = isUnread
|
||||
}
|
||||
}
|
||||
|
||||
@ -436,14 +438,14 @@ extension EngineChatList.Item {
|
||||
if let forumTopicData = forumTopicData {
|
||||
let id = forumTopicData.id
|
||||
if let forumTopicData = forumTopicData.info.data.get(MessageHistoryThreadData.self) {
|
||||
forumTopicDataValue = EngineChatList.ForumTopicData(id: id, title: forumTopicData.info.title, iconFileId: forumTopicData.info.icon, iconColor: forumTopicData.info.iconColor, maxOutgoingReadMessageId: MessageId(peerId: index.messageIndex.id.peerId, namespace: Namespaces.Message.Cloud, id: forumTopicData.maxOutgoingReadId))
|
||||
forumTopicDataValue = EngineChatList.ForumTopicData(id: id, title: forumTopicData.info.title, iconFileId: forumTopicData.info.icon, iconColor: forumTopicData.info.iconColor, maxOutgoingReadMessageId: MessageId(peerId: index.messageIndex.id.peerId, namespace: Namespaces.Message.Cloud, id: forumTopicData.maxOutgoingReadId), isUnread: forumTopicData.incomingUnreadCount > 0)
|
||||
}
|
||||
}
|
||||
|
||||
var topForumTopicItems: [EngineChatList.ForumTopicData] = []
|
||||
for item in topForumTopics {
|
||||
if let forumTopicData = item.info.data.get(MessageHistoryThreadData.self) {
|
||||
topForumTopicItems.append(EngineChatList.ForumTopicData(id: item.id, title: forumTopicData.info.title, iconFileId: forumTopicData.info.icon, iconColor: forumTopicData.info.iconColor, maxOutgoingReadMessageId: MessageId(peerId: index.messageIndex.id.peerId, namespace: Namespaces.Message.Cloud, id: forumTopicData.maxOutgoingReadId)))
|
||||
topForumTopicItems.append(EngineChatList.ForumTopicData(id: item.id, title: forumTopicData.info.title, iconFileId: forumTopicData.info.icon, iconColor: forumTopicData.info.iconColor, maxOutgoingReadMessageId: MessageId(peerId: index.messageIndex.id.peerId, namespace: Namespaces.Message.Cloud, id: forumTopicData.maxOutgoingReadId), isUnread: forumTopicData.incomingUnreadCount > 0))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -859,17 +859,23 @@ public extension TelegramEngine {
|
||||
}
|
||||
|
||||
public func toggleForumChannelTopicPinned(id: EnginePeer.Id, threadId: Int64) -> Signal<Never, SetForumChannelTopicPinnedError> {
|
||||
return self.account.postbox.transaction { transaction -> [Int64] in
|
||||
return transaction.getPeerPinnedThreads(peerId: id)
|
||||
return self.account.postbox.transaction { transaction -> ([Int64], Int) in
|
||||
var limit = 5
|
||||
let appConfiguration: AppConfiguration = transaction.getPreferencesEntry(key: PreferencesKeys.appConfiguration)?.get(AppConfiguration.self) ?? AppConfiguration.defaultValue
|
||||
if let data = appConfiguration.data, let value = data["topics_pinned_limit"] as? Double {
|
||||
limit = Int(value)
|
||||
}
|
||||
|
||||
return (transaction.getPeerPinnedThreads(peerId: id), limit)
|
||||
}
|
||||
|> castError(SetForumChannelTopicPinnedError.self)
|
||||
|> mapToSignal { threadIds -> Signal<Never, SetForumChannelTopicPinnedError> in
|
||||
|> mapToSignal { threadIds, limit -> Signal<Never, SetForumChannelTopicPinnedError> in
|
||||
var threadIds = threadIds
|
||||
if threadIds.contains(threadId) {
|
||||
threadIds.removeAll(where: { $0 == threadId })
|
||||
} else {
|
||||
if threadIds.count + 1 > 5 {
|
||||
return .fail(.limitReached(5))
|
||||
if threadIds.count + 1 > limit {
|
||||
return .fail(.limitReached(limit))
|
||||
}
|
||||
threadIds.insert(threadId, at: 0)
|
||||
}
|
||||
|
@ -110,9 +110,9 @@ func chatHistoryViewForLocation(_ location: ChatHistoryLocationInput, ignoreMess
|
||||
canScrollToRead = false
|
||||
}
|
||||
|
||||
if case let .replyThread(message) = chatLocation, message.isForumPost {
|
||||
if tagMask == nil, case let .replyThread(message) = chatLocation, message.isForumPost, view.maxReadIndex == nil {
|
||||
if case let .message(index) = view.anchorIndex {
|
||||
scrollPosition = .index(index: .message(index), position: .top(0.0), directionHint: .Up, animated: false, highlight: false, displayLink: false)
|
||||
scrollPosition = .index(index: .message(index), position: .bottom(0.0), directionHint: .Up, animated: false, highlight: false, displayLink: false)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user