Skip to content

Commit b4888f1

Browse files
authored
Don't offer Mark As Unread for chats with topics (#190)
For groups with topics, channel direct messages and bots with topics, TelegramCore's unread toggle only marks topics as read, so Mark As Unread in the chat list did nothing. As on iOS, the context menu and VoiceOver actions no longer offer it, the swipe button is left out when nothing is unread, and a row with nothing to show on the left doesn't slide.
1 parent 036b429 commit b4888f1

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎packages/ChatListUI/Sources/ChatListUI/ChatListRowItem.swift‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,11 @@ public class ChatListRowItem: TableRowItem {
15221522
}
15231523

15241524
public var markAsUnread: Bool {
1525-
return !isSecret && !isUnreadMarked && badgeNode == nil && !showsMentionSlot && !self.mode.savedMessages
1525+
return !isSecret && !isUnreadMarked && badgeNode == nil && !showsMentionSlot && !self.mode.savedMessages && peer?.isForumOrMonoForum != true
1526+
}
1527+
1528+
public var canToggleUnread: Bool {
1529+
return peer?.isForumOrMonoForum != true || badgeNode != nil || showsMentionSlot || isUnreadMarked
15261530
}
15271531

15281532
public func collapseOrExpandArchive() {

‎packages/ChatListUI/Sources/ChatListUI/ChatListRowView.swift‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2734,7 +2734,7 @@ public class ChatListRowView: TableRowView, RevealTableView {
27342734
}
27352735

27362736

2737-
if !item.isTopic {
2737+
if !item.isTopic, item.canToggleUnread {
27382738
revealLeftView.addSubview(unread)
27392739
revealLeftView.backgroundColor = .clear
27402740
}
@@ -2872,6 +2872,7 @@ public class ChatListRowView: TableRowView, RevealTableView {
28722872
private var animateOnceAfterDelta: Bool = true
28732873
private var revealHighlighted: Bool = false
28742874
public func moveReveal(delta: CGFloat) {
2875+
let delta = revealLeftView.subviews.isEmpty ? min(delta, 0) : delta
28752876

28762877
if !revealHighlighted, delta != 0, let item = item as? ChatListRowItem, !item.isSelected, let table = item.table {
28772878
_ = table.highlight(item: item)

0 commit comments

Comments
 (0)