Loading app/core/src/main/java/com/fsck/k9/notification/NotificationDataStore.kt +5 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,11 @@ internal const val MAX_NUMBER_OF_NEW_MESSAGE_NOTIFICATIONS = 8 internal class NotificationDataStore { private val notificationDataMap = mutableMapOf<String, NotificationData>() @Synchronized fun isAccountInitialized(account: Account): Boolean { return notificationDataMap[account.uuid] != null } @Synchronized fun initializeAccount( account: Account, Loading app/core/src/main/java/com/fsck/k9/notification/NotificationRepository.kt +13 −3 Original line number Diff line number Diff line Loading @@ -15,14 +15,14 @@ internal class NotificationRepository( @Synchronized fun restoreNotifications(account: Account): NotificationData? { if (notificationDataStore.isAccountInitialized(account)) return null val localStore = localStoreProvider.getInstance(account) val (activeNotificationMessages, inactiveNotificationMessages) = localStore.notificationMessages.partition { it.notificationId != null } if (activeNotificationMessages.isEmpty()) return null val activeNotifications = activeNotificationMessages.map { notificationMessage -> val content = notificationContentCreator.createFromMessage(account, notificationMessage.message) NotificationHolder(notificationMessage.notificationId!!, notificationMessage.timestamp, content) Loading @@ -33,11 +33,19 @@ internal class NotificationRepository( InactiveNotificationHolder(notificationMessage.timestamp, content) } return notificationDataStore.initializeAccount(account, activeNotifications, inactiveNotifications) val notificationData = notificationDataStore.initializeAccount( account, activeNotifications, inactiveNotifications ) return if (notificationData.activeNotifications.isNotEmpty()) notificationData else null } @Synchronized fun addNotification(account: Account, content: NotificationContent, timestamp: Long): AddNotificationResult? { restoreNotifications(account) return notificationDataStore.addNotification(account, content, timestamp)?.also { result -> persistNotificationDataStoreChanges( account = account, Loading @@ -53,6 +61,8 @@ internal class NotificationRepository( clearNewMessageState: Boolean = true, selector: (List<MessageReference>) -> List<MessageReference> ): RemoveNotificationsResult? { restoreNotifications(account) return notificationDataStore.removeNotifications(account, selector)?.also { result -> persistNotificationDataStoreChanges( account = account, Loading Loading
app/core/src/main/java/com/fsck/k9/notification/NotificationDataStore.kt +5 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,11 @@ internal const val MAX_NUMBER_OF_NEW_MESSAGE_NOTIFICATIONS = 8 internal class NotificationDataStore { private val notificationDataMap = mutableMapOf<String, NotificationData>() @Synchronized fun isAccountInitialized(account: Account): Boolean { return notificationDataMap[account.uuid] != null } @Synchronized fun initializeAccount( account: Account, Loading
app/core/src/main/java/com/fsck/k9/notification/NotificationRepository.kt +13 −3 Original line number Diff line number Diff line Loading @@ -15,14 +15,14 @@ internal class NotificationRepository( @Synchronized fun restoreNotifications(account: Account): NotificationData? { if (notificationDataStore.isAccountInitialized(account)) return null val localStore = localStoreProvider.getInstance(account) val (activeNotificationMessages, inactiveNotificationMessages) = localStore.notificationMessages.partition { it.notificationId != null } if (activeNotificationMessages.isEmpty()) return null val activeNotifications = activeNotificationMessages.map { notificationMessage -> val content = notificationContentCreator.createFromMessage(account, notificationMessage.message) NotificationHolder(notificationMessage.notificationId!!, notificationMessage.timestamp, content) Loading @@ -33,11 +33,19 @@ internal class NotificationRepository( InactiveNotificationHolder(notificationMessage.timestamp, content) } return notificationDataStore.initializeAccount(account, activeNotifications, inactiveNotifications) val notificationData = notificationDataStore.initializeAccount( account, activeNotifications, inactiveNotifications ) return if (notificationData.activeNotifications.isNotEmpty()) notificationData else null } @Synchronized fun addNotification(account: Account, content: NotificationContent, timestamp: Long): AddNotificationResult? { restoreNotifications(account) return notificationDataStore.addNotification(account, content, timestamp)?.also { result -> persistNotificationDataStoreChanges( account = account, Loading @@ -53,6 +61,8 @@ internal class NotificationRepository( clearNewMessageState: Boolean = true, selector: (List<MessageReference>) -> List<MessageReference> ): RemoveNotificationsResult? { restoreNotifications(account) return notificationDataStore.removeNotifications(account, selector)?.also { result -> persistNotificationDataStoreChanges( account = account, Loading