From 72d434bfbec49f6f2f5a16ea072acf3eeb2fb2ea Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Wed, 22 Feb 2023 10:31:41 +0600 Subject: [PATCH 1/2] 6688-Fix_drawer_headerView_selection_not_updating issue: https://gitlab.e.foundation/e/backlog/-/issues/6688 on prefence update, headerView update was not calling because of `if` check (that is added in cbc3d20c91358d44a8c5ab454faedd2e00bc3097 to resolve multiple profile selected at a time issue). To resolve both these issues, the equal check is removed on update & headerView is reconstructed on activeProfile switch. --- .../legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt index 32dc6ab177..8e97c08628 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt @@ -146,10 +146,8 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K accountsViewModel.displayAccountsLiveData.observeNotNull(parent) { accounts -> run { - if (accounts != displayAccounts) { - displayAccounts = accounts - setAccounts(accounts) - } + displayAccounts = accounts + setAccounts(accounts) } } @@ -279,7 +277,12 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K headerView.addProfiles(*accountItems) newActiveProfile?.let { profile -> + if (profile == headerView.activeProfile) { + return@let + } + headerView.activeProfile = profile + headerView.updateHeaderAndList() } if (oldSelectedBackgroundColor != selectedBackgroundColor) { -- GitLab From a37834d2f9bfd5944c7ece0478bcdc9efdfe910e Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Wed, 22 Feb 2023 12:35:18 +0600 Subject: [PATCH 2/2] Replace if check inside let statement with takeIf --- .../legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt index 8e97c08628..7ede9fa28a 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt @@ -276,15 +276,14 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K headerView.clear() headerView.addProfiles(*accountItems) - newActiveProfile?.let { profile -> - if (profile == headerView.activeProfile) { - return@let + newActiveProfile + ?.takeIf { + it != headerView.activeProfile + }?.let { + headerView.activeProfile = it + headerView.updateHeaderAndList() } - headerView.activeProfile = profile - headerView.updateHeaderAndList() - } - if (oldSelectedBackgroundColor != selectedBackgroundColor) { // Recreate list of folders with updated account color setUserFolders(latestFolderList) -- GitLab