Commit b01dbe5a5d

b01dbe5a5da9798b5cbc6e8b3ddbeea3aa37f072

parent: 4b2382bf93

Unregistered key

vaw <git@nlih.de> · 2025-10-25 20:22 UTC
committer: <noreply@github.com>

Add more compatibility for unreads (#451)

Layout: unified · split

src/base.rs +22 −2
@@ -1133,14 +1133,34 @@ impl RoomInfo {
11331133 /// Indicates whether this room has unread messages.
11341134 pub fn unreads(&self, settings: &ApplicationSettings) -> UnreadInfo {
11351135 let last_message = self.messages.last_key_value();
1136
11361137 let last_receipt = self
11371138 .user_receipts
11381139 .get(&ReceiptThread::Main)
11391140 .and_then(|receipts| receipts.get(&settings.profile.user_id));
1141 let last_receipt = last_receipt.as_ref().and_then(|event_id| {
1142 match &self.keys.get(*event_id)? {
1143 EventLocation::Message(_, key) | EventLocation::State(key) => Some(key),
1144 EventLocation::Reaction(_) => None,
1145 }
1146 });
1147
1148 let last_unthreaded = self
1149 .user_receipts
1150 .get(&ReceiptThread::Unthreaded)
1151 .and_then(|receipts| receipts.get(&settings.profile.user_id));
1152 let last_unthreaded = last_unthreaded.as_ref().and_then(|event_id| {
1153 match &self.keys.get(*event_id)? {
1154 EventLocation::Message(_, key) | EventLocation::State(key) => Some(key),
1155 EventLocation::Reaction(_) => None,
1156 }
1157 });
1158
1159 let last_receipt = std::cmp::max(last_receipt, last_unthreaded);
11401160
11411161 match (last_message, last_receipt) {
1142 (Some(((ts, recent), _)), Some(last_read)) => {
1143 UnreadInfo { unread: last_read != recent, latest: Some(*ts) }
1162 (Some(((ts, _), _)), Some((read_ts, _))) => {
1163 UnreadInfo { unread: ts > read_ts, latest: Some(*ts) }
11441164 },
11451165 (Some(((ts, _), _)), None) => {
11461166 // If we've never loaded/generated a room's receipt (example,