From bef94b99e7a338017db5ae82571aedc2b0aadb27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Fri, 26 Jun 2026 18:37:10 +0200 Subject: [PATCH] fix: Don't show read marker without message afterwards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- NextcloudTalk/Chat/ChatViewController.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/NextcloudTalk/Chat/ChatViewController.swift b/NextcloudTalk/Chat/ChatViewController.swift index 73f6acfd8..019c52af0 100644 --- a/NextcloudTalk/Chat/ChatViewController.swift +++ b/NextcloudTalk/Chat/ChatViewController.swift @@ -1450,6 +1450,8 @@ import SwiftUI if let lastMessage, lastMessage.messageId > self.lastReadMessage { // Iterate backwards to find the correct location for the unread message separator + var foundOneMessage = false + for sectionIndex in self.dateSections.indices.reversed() { let dateSection: Date = self.dateSections[sectionIndex] @@ -1458,6 +1460,14 @@ import SwiftUI for messageIndex in messages.indices.reversed() { let message = messages[messageIndex] + // The unread marker should never be inserted after the first message, as that would + // show it without any message afterwards. Therefore we check if we found at least one + // message, before adding the marker + if !foundOneMessage { + foundOneMessage = true + continue + } + if message.messageId > self.lastReadMessage { continue }