Loading app/core/src/main/java/com/fsck/k9/Preferences.kt +2 −6 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package com.fsck.k9 import android.content.Context import androidx.annotation.GuardedBy import androidx.annotation.RestrictTo import com.fsck.k9.helper.sendBlockingSilently import com.fsck.k9.mail.MessagingException import com.fsck.k9.mailstore.LocalStoreProvider import com.fsck.k9.preferences.AccountManager Loading @@ -18,7 +19,6 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.channels.sendBlocking import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.buffer import kotlinx.coroutines.flow.callbackFlow Loading Loading @@ -126,11 +126,7 @@ class Preferences internal constructor( val listener = AccountsChangeListener { val account = getAccount(accountUuid) if (account != null) { try { sendBlocking(account) } catch (e: Exception) { Timber.w(e, "Error while trying to send to channel") } sendBlockingSilently(account) } else { channel.close() } Loading app/core/src/main/java/com/fsck/k9/helper/CallbackFlowHelper.kt 0 → 100644 +16 −0 Original line number Diff line number Diff line package com.fsck.k9.helper import kotlinx.coroutines.channels.ClosedSendChannelException import kotlinx.coroutines.channels.SendChannel import kotlinx.coroutines.channels.sendBlocking /** * Like [sendBlocking], but ignores [ClosedSendChannelException]. */ fun <E> SendChannel<E>.sendBlockingSilently(element: E) { try { sendBlocking(element) } catch (e: ClosedSendChannelException) { // Ignore } } app/core/src/main/java/com/fsck/k9/mailstore/FolderRepository.kt +3 −7 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import com.fsck.k9.Account.FolderMode import com.fsck.k9.DI import com.fsck.k9.controller.MessagingController import com.fsck.k9.controller.SimpleMessagingListener import com.fsck.k9.helper.sendBlockingSilently import com.fsck.k9.mail.FolderClass import com.fsck.k9.preferences.AccountManager import kotlinx.coroutines.CoroutineDispatcher Loading @@ -19,7 +20,6 @@ import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch import com.fsck.k9.mail.FolderType as RemoteFolderType @OptIn(ExperimentalCoroutinesApi::class) Loading Loading @@ -64,9 +64,7 @@ class FolderRepository( val listener = object : SimpleMessagingListener() { override fun folderStatusChanged(statusChangedAccount: Account, folderId: Long) { if (statusChangedAccount.uuid == account.uuid) { launch { send(getDisplayFolders(account, displayMode)) } sendBlockingSilently(getDisplayFolders(account, displayMode)) } } } Loading Loading @@ -168,9 +166,7 @@ class FolderRepository( send(getPushFolders(account, folderMode)) val listener = FolderSettingsChangedListener { launch { send(getPushFolders(account, folderMode)) } sendBlockingSilently(getPushFolders(account, folderMode)) } messageStore.addFolderSettingsChangedListener(listener) Loading app/ui/legacy/src/main/java/com/fsck/k9/ui/account/AccountsViewModel.kt +2 −3 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import com.fsck.k9.AccountsChangeListener import com.fsck.k9.Preferences import com.fsck.k9.controller.MessageCounts import com.fsck.k9.controller.MessageCountsProvider import com.fsck.k9.helper.sendBlockingSilently import com.fsck.k9.provider.EmailProvider import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi Loading @@ -34,9 +35,7 @@ class AccountsViewModel( send(preferences.accounts) val accountsChangeListener = AccountsChangeListener { launch { send(preferences.accounts) } sendBlockingSilently(preferences.accounts) } preferences.addOnAccountsChangeListener(accountsChangeListener) Loading Loading
app/core/src/main/java/com/fsck/k9/Preferences.kt +2 −6 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package com.fsck.k9 import android.content.Context import androidx.annotation.GuardedBy import androidx.annotation.RestrictTo import com.fsck.k9.helper.sendBlockingSilently import com.fsck.k9.mail.MessagingException import com.fsck.k9.mailstore.LocalStoreProvider import com.fsck.k9.preferences.AccountManager Loading @@ -18,7 +19,6 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.channels.sendBlocking import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.buffer import kotlinx.coroutines.flow.callbackFlow Loading Loading @@ -126,11 +126,7 @@ class Preferences internal constructor( val listener = AccountsChangeListener { val account = getAccount(accountUuid) if (account != null) { try { sendBlocking(account) } catch (e: Exception) { Timber.w(e, "Error while trying to send to channel") } sendBlockingSilently(account) } else { channel.close() } Loading
app/core/src/main/java/com/fsck/k9/helper/CallbackFlowHelper.kt 0 → 100644 +16 −0 Original line number Diff line number Diff line package com.fsck.k9.helper import kotlinx.coroutines.channels.ClosedSendChannelException import kotlinx.coroutines.channels.SendChannel import kotlinx.coroutines.channels.sendBlocking /** * Like [sendBlocking], but ignores [ClosedSendChannelException]. */ fun <E> SendChannel<E>.sendBlockingSilently(element: E) { try { sendBlocking(element) } catch (e: ClosedSendChannelException) { // Ignore } }
app/core/src/main/java/com/fsck/k9/mailstore/FolderRepository.kt +3 −7 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import com.fsck.k9.Account.FolderMode import com.fsck.k9.DI import com.fsck.k9.controller.MessagingController import com.fsck.k9.controller.SimpleMessagingListener import com.fsck.k9.helper.sendBlockingSilently import com.fsck.k9.mail.FolderClass import com.fsck.k9.preferences.AccountManager import kotlinx.coroutines.CoroutineDispatcher Loading @@ -19,7 +20,6 @@ import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch import com.fsck.k9.mail.FolderType as RemoteFolderType @OptIn(ExperimentalCoroutinesApi::class) Loading Loading @@ -64,9 +64,7 @@ class FolderRepository( val listener = object : SimpleMessagingListener() { override fun folderStatusChanged(statusChangedAccount: Account, folderId: Long) { if (statusChangedAccount.uuid == account.uuid) { launch { send(getDisplayFolders(account, displayMode)) } sendBlockingSilently(getDisplayFolders(account, displayMode)) } } } Loading Loading @@ -168,9 +166,7 @@ class FolderRepository( send(getPushFolders(account, folderMode)) val listener = FolderSettingsChangedListener { launch { send(getPushFolders(account, folderMode)) } sendBlockingSilently(getPushFolders(account, folderMode)) } messageStore.addFolderSettingsChangedListener(listener) Loading
app/ui/legacy/src/main/java/com/fsck/k9/ui/account/AccountsViewModel.kt +2 −3 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import com.fsck.k9.AccountsChangeListener import com.fsck.k9.Preferences import com.fsck.k9.controller.MessageCounts import com.fsck.k9.controller.MessageCountsProvider import com.fsck.k9.helper.sendBlockingSilently import com.fsck.k9.provider.EmailProvider import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi Loading @@ -34,9 +35,7 @@ class AccountsViewModel( send(preferences.accounts) val accountsChangeListener = AccountsChangeListener { launch { send(preferences.accounts) } sendBlockingSilently(preferences.accounts) } preferences.addOnAccountsChangeListener(accountsChangeListener) Loading