Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes New menu forgets its "Hide accounts" setting #8735

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions feature/navigation/drawer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies {
implementation(projects.legacy.message)
implementation(projects.legacy.search)
implementation(projects.legacy.ui.folder)
implementation(projects.legacy.core)

testImplementation(projects.core.ui.compose.testing)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import app.k9mail.core.ui.compose.common.mvi.UnidirectionalViewModel
import app.k9mail.feature.navigation.drawer.NavigationDrawerExternalContract.DrawerConfig
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayAccount
import app.k9mail.feature.navigation.drawer.domain.entity.DisplayFolder
import com.fsck.k9.K9
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf

Expand All @@ -22,7 +23,7 @@ internal interface DrawerContract {
val selectedAccountId: String? = null,
val folders: ImmutableList<DisplayFolder> = persistentListOf(),
val selectedFolderId: String? = null,
val showAccountSelector: Boolean = true,
val showAccountSelector: Boolean = K9.isShowAccountSelector,
val isLoading: Boolean = false,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import app.k9mail.feature.navigation.drawer.ui.DrawerContract.Effect
import app.k9mail.feature.navigation.drawer.ui.DrawerContract.Event
import app.k9mail.feature.navigation.drawer.ui.DrawerContract.State
import app.k9mail.feature.navigation.drawer.ui.DrawerContract.ViewModel
import com.fsck.k9.K9
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand Down Expand Up @@ -113,7 +114,11 @@ internal class DrawerViewModel(
)
}

Event.OnAccountSelectorClick -> updateState { it.copy(showAccountSelector = it.showAccountSelector.not()) }
Event.OnAccountSelectorClick -> updateState {
K9.isShowAccountSelector = it.showAccountSelector.not()
K9.saveSettingsAsync()
it.copy(showAccountSelector = it.showAccountSelector.not())
}
Event.OnManageFoldersClick -> emitEffect(Effect.OpenManageFolders)
Event.OnSettingsClick -> emitEffect(Effect.OpenSettings)
Event.OnSyncAccount -> onSyncAccount()
Expand Down
5 changes: 5 additions & 0 deletions legacy/core/src/main/java/com/fsck/k9/K9.kt
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ object K9 : KoinComponent {
@JvmStatic
var isShowUnifiedInbox = false

@JvmStatic
var isShowAccountSelector = true

@JvmStatic
var isShowStarredCount = false

Expand Down Expand Up @@ -329,6 +332,7 @@ object K9 : KoinComponent {
isShowAnimations = storage.getBoolean("animations", true)
isUseVolumeKeysForNavigation = storage.getBoolean("useVolumeKeysForNavigation", false)
isShowUnifiedInbox = storage.getBoolean("showUnifiedInbox", false)
isShowAccountSelector = storage.getBoolean("showAccountSelector", true)
isShowStarredCount = storage.getBoolean("showStarredCount", false)
isMessageListSenderAboveSubject = storage.getBoolean("messageListSenderAboveSubject", false)
isShowMessageListStars = storage.getBoolean("messageListStars", true)
Expand Down Expand Up @@ -424,6 +428,7 @@ object K9 : KoinComponent {
editor.putEnum("messageListDensity", messageListDensity)
editor.putBoolean("messageListSenderAboveSubject", isMessageListSenderAboveSubject)
editor.putBoolean("showUnifiedInbox", isShowUnifiedInbox)
editor.putBoolean("showAccountSelector", isShowAccountSelector)
editor.putBoolean("showStarredCount", isShowStarredCount)
editor.putBoolean("messageListStars", isShowMessageListStars)
editor.putInt("messageListPreviewLines", messageListPreviewLines)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ class GeneralSettingsDescriptions {
new V(69, new BooleanSetting(true)),
new V(101, new BooleanSetting(false))
));
s.put("isShowAccountSelector", Settings.versions(
new V(102, new BooleanSetting(true))
));
s.put("sortTypeEnum", Settings.versions(
new V(10, new EnumSetting<>(SortType.class, Account.DEFAULT_SORT_TYPE))
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Settings {
*
* @see SettingsExporter
*/
public static final int VERSION = 101;
public static final int VERSION = 102;

static Map<String, Object> validate(int version, Map<String, TreeMap<Integer, SettingsDescription<?>>> settings,
Map<String, String> importedSettings, boolean useDefaultValues) {
Expand Down