From 2e1b002b210e1a8e1662acce79ef644b50f69426 Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 21 Sep 2021 14:30:32 +0200 Subject: [PATCH] Update displayed folder list when folders on server have changed --- .../java/com/fsck/k9/mailstore/FolderRepository.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/FolderRepository.kt b/app/core/src/main/java/com/fsck/k9/mailstore/FolderRepository.kt index 14dc62418..f40136d34 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/FolderRepository.kt +++ b/app/core/src/main/java/com/fsck/k9/mailstore/FolderRepository.kt @@ -57,21 +57,28 @@ class FolderRepository( fun getDisplayFoldersFlow(account: Account, displayMode: FolderMode): Flow> { val messagingController = DI.get() + val messageStore = messageStoreManager.getMessageStore(account) return callbackFlow { send(getDisplayFolders(account, displayMode)) - val listener = object : SimpleMessagingListener() { + val folderStatusChangedListener = object : SimpleMessagingListener() { override fun folderStatusChanged(statusChangedAccount: Account, folderId: Long) { if (statusChangedAccount.uuid == account.uuid) { sendBlockingSilently(getDisplayFolders(account, displayMode)) } } } - messagingController.addListener(listener) + messagingController.addListener(folderStatusChangedListener) + + val folderSettingsChangedListener = FolderSettingsChangedListener { + sendBlockingSilently(getDisplayFolders(account, displayMode)) + } + messageStore.addFolderSettingsChangedListener(folderSettingsChangedListener) awaitClose { - messagingController.removeListener(listener) + messagingController.removeListener(folderStatusChangedListener) + messageStore.removeFolderSettingsChangedListener(folderSettingsChangedListener) } }.buffer(capacity = Channel.CONFLATED) .distinctUntilChanged()