From d204340d5d0d9642e1ec0b3538296274a14e88db Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Wed, 27 Aug 2025 08:18:34 -0700 Subject: [PATCH] Revert "Remove redundant gotFirstUnreadMessage " --- Meshtastic/Views/Messages/ChannelMessageList.swift | 3 +++ Meshtastic/Views/Messages/UserMessageList.swift | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Meshtastic/Views/Messages/ChannelMessageList.swift b/Meshtastic/Views/Messages/ChannelMessageList.swift index 45675170..4435adb4 100644 --- a/Meshtastic/Views/Messages/ChannelMessageList.swift +++ b/Meshtastic/Views/Messages/ChannelMessageList.swift @@ -23,6 +23,7 @@ struct ChannelMessageList: View { // Scroll state @State private var showScrollToBottomButton = false @State private var hasReachedBottom = false + @State private var gotFirstUnreadMessage: Bool = false @State private var messageToHighlight: Int64 = 0 @@ -163,6 +164,7 @@ struct ChannelMessageList: View { .frame(maxWidth: .infinity) .id(message.messageId) .onAppear { + if gotFirstUnreadMessage { if !message.read { message.read = true do { @@ -182,6 +184,7 @@ struct ChannelMessageList: View { hasReachedBottom = true showScrollToBottomButton = false } + } } } // Invisible spacer to detect reaching bottom diff --git a/Meshtastic/Views/Messages/UserMessageList.swift b/Meshtastic/Views/Messages/UserMessageList.swift index 00bd6062..15af373b 100644 --- a/Meshtastic/Views/Messages/UserMessageList.swift +++ b/Meshtastic/Views/Messages/UserMessageList.swift @@ -22,6 +22,7 @@ struct UserMessageList: View { // Scroll state @State private var showScrollToBottomButton = false @State private var hasReachedBottom = false + @State private var gotFirstUnreadMessage: Bool = false @State private var messageToHighlight: Int64 = 0 var body: some View { @@ -131,6 +132,7 @@ struct UserMessageList: View { .frame(maxWidth: .infinity) .id(message.messageId) .onAppear { + if gotFirstUnreadMessage { if !message.read { message.read = true do { @@ -149,6 +151,7 @@ struct UserMessageList: View { hasReachedBottom = true showScrollToBottomButton = false } + } } } } @@ -177,6 +180,7 @@ struct UserMessageList: View { } } } + gotFirstUnreadMessage = true } .onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardDidShowNotification)) { _ in withAnimation {