Optimize persistence

This commit is contained in:
Hillel Coren 2021-08-25 10:16:33 +03:00
parent e3226ae2e8
commit 047ee4abe6
2 changed files with 4 additions and 4 deletions

View File

@ -383,7 +383,7 @@ Middleware<AppState> _createUserLoggedIn(
uiRepository.saveUIState(state.uiState); uiRepository.saveUIState(state.uiState);
staticRepository.saveStaticState(state.staticState); staticRepository.saveStaticState(state.staticState);
if (state.prefState.persistData) { if (state.prefState.persistData || state.company.isSmall) {
for (var i = 0; i < state.userCompanyStates.length; i++) { for (var i = 0; i < state.userCompanyStates.length; i++) {
companyRepositories[i].saveCompanyState(state.userCompanyStates[i]); companyRepositories[i].saveCompanyState(state.userCompanyStates[i]);
} }
@ -403,7 +403,7 @@ Middleware<AppState> _createPersistData(
final index = state.uiState.selectedCompanyIndex; final index = state.uiState.selectedCompanyIndex;
final companyState = state.userCompanyStates[index]; final companyState = state.userCompanyStates[index];
if (state.prefState.persistData) { if (state.prefState.persistData || state.company.isSmall) {
companyRepositories[index].saveCompanyState(companyState); companyRepositories[index].saveCompanyState(companyState);
} }
}; };

View File

@ -27,7 +27,7 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
showFilterSidebar: false, showFilterSidebar: false,
longPressSelectionIsDefault: true, longPressSelectionIsDefault: true,
showKanban: false, showKanban: false,
persistData: true, persistData: !kIsWeb,
companyPrefs: BuiltMap<String, CompanyPrefState>(), companyPrefs: BuiltMap<String, CompanyPrefState>(),
sortFields: BuiltMap<EntityType, PrefStateSortField>(), sortFields: BuiltMap<EntityType, PrefStateSortField>(),
customColors: BuiltMap<String, String>(), customColors: BuiltMap<String, String>(),
@ -166,7 +166,7 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
: BuiltMap<String, String>(PrefState.CONTRAST_COLORS)) : BuiltMap<String, String>(PrefState.CONTRAST_COLORS))
..showKanban = false ..showKanban = false
..isPreviewEnabled = true ..isPreviewEnabled = true
..persistData = true ..persistData = !kIsWeb
..colorTheme = ..colorTheme =
builder.enableDarkMode == true ? kColorThemeLight : kColorThemeLight; builder.enableDarkMode == true ? kColorThemeLight : kColorThemeLight;