Skip to content

Commit

Permalink
fix: persist forced offline mode (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
irishrain authored Dec 30, 2024
1 parent 02f3387 commit e09034f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kitchenowl/lib/cubits/auth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class AuthCubit extends Cubit<AuthState> {
.then((value) => value ?? token);
});
}
_loadForcedOfflineMode();
setup();
}

Expand Down Expand Up @@ -277,8 +278,13 @@ class AuthCubit extends Cubit<AuthState> {
}
}

Future<void> _loadForcedOfflineMode() async {
_forcedOfflineMode = await PreferenceStorage.getInstance().readBool(key: 'forcedOfflineMode') ?? false;
}

void setForcedOfflineMode(bool forcedOfflineMode) async {
_forcedOfflineMode = forcedOfflineMode;
await PreferenceStorage.getInstance().writeBool(key: 'forcedOfflineMode', value: forcedOfflineMode);
updateState(); // force refresh if state stays the same
refresh();
}
Expand Down

0 comments on commit e09034f

Please sign in to comment.