Repository: thundernest/k-9
Issue: With 5.909, frequent blank screen when opening a message

### Checklist

- [X] I have used the search function to see if someone else has already submitted the same bug report.
- [X] I will describe the problem with as much detail as possible.

### App version

5.909

### Where did you get the app from?

Google Play

### Android version

12

### Device model

Pixel 6

### Steps to reproduce

1. View message list
2. Tap a message to open it

### Expected behavior

Message displays

### Actual behavior

I briefly see the loading progress bar at the top of the screen show activity, and then I am left with a completely blank screen. If I go back and tap the same message again it displays the second time.

### Logs

_No response_

Changed files:
app/core/src/main/java/com/fsck/k9/notification/NotificationRepository.kt

diff --git a/app/core/src/main/java/com/fsck/k9/notification/NotificationRepository.kt b/app/core/src/main/java/com/fsck/k9/notification/NotificationRepository.kt
index b18f3686a..f624810c9 100644
--- a/app/core/src/main/java/com/fsck/k9/notification/NotificationRepository.kt
+++ b/app/core/src/main/java/com/fsck/k9/notification/NotificationRepository.kt
@@ -39,7 +39,11 @@ internal class NotificationRepository(
     @Synchronized
     fun addNotification(account: Account, content: NotificationContent, timestamp: Long): AddNotificationResult {
         return notificationDataStore.addNotification(account, content, timestamp).also { result ->
-            persistNotificationDataStoreChanges(account, result.notificationStoreOperations)
+            persistNotificationDataStoreChanges(
+                account = account,
+                operations = result.notificationStoreOperations,
+                updateNewMessageState = true
+            )
         }
     }
 
@@ -50,9 +54,11 @@ internal class NotificationRepository(
         selector: (List<MessageReference>) -> List<MessageReference>
     ): RemoveNotificationsResult? {
         return notificationDataStore.removeNotifications(account, selector)?.also { result ->
-            if (clearNewMessageState) {
-                persistNotificationDataStoreChanges(account, result.notificationStoreOperations)
-            }
+            persistNotificationDataStoreChanges(
+                account = account,
+                operations = result.notificationStoreOperations,
+                updateNewMessageState = clearNewMessageState
+            )
         }
     }
 
@@ -66,11 +72,17 @@ internal class NotificationRepository(
         }
     }
 
-    private fun persistNotificationDataStoreChanges(account: Account, operations: List<NotificationStoreOperation>) {
+    private fun persistNotificationDataStoreChanges(
+        account: Account,
+        operations: List<NotificationStoreOperation>,
+        updateNewMessageState: Boolean
+    ) {
         val notificationStore = notificationStoreProvider.getNotificationStore(account)
         notificationStore.persistNotificationChanges(operations)
 
-        setNewMessageState(account, operations)
+        if (updateNewMessageState) {
+            setNewMessageState(account, operations)
+        }
     }
 
     private fun setNewMessageState(account: Account, operations: List<NotificationStoreOperation>) {