Always load on refresh

This commit is contained in:
Hillel Coren 2020-10-29 22:32:18 +02:00
parent 31a3b321ac
commit 604efffd00
2 changed files with 8 additions and 7 deletions

View File

@ -154,6 +154,7 @@ class RefreshData implements StartLoading {
this.includeStatic = false,
});
final Completer completer;
final bool clearData;
final bool includeStatic;

View File

@ -179,6 +179,7 @@ Middleware<AppState> _createLoadState(
return (Store<AppState> store, dynamic dynamicAction,
NextDispatcher next) async {
final action = dynamicAction as LoadStateRequest;
try {
final prefs = await SharedPreferences.getInstance();
final appVersion = prefs.getString(kSharedPrefAppVersion);
@ -219,13 +220,11 @@ Middleware<AppState> _createLoadState(
AppBuilder.of(action.context).rebuild();
store.dispatch(LoadStateSuccess(appState));
if (appState.isStale) {
store.dispatch(RefreshData(
completer: Completer<Null>()
..future.catchError(() {
store.dispatch(UserLogout(action.context));
})));
}
store.dispatch(RefreshData(
completer: Completer<Null>()
..future.catchError(() {
store.dispatch(UserLogout(action.context));
})));
if (uiState.currentRoute != LoginScreen.route &&
uiState.currentRoute.isNotEmpty) {
@ -284,6 +283,7 @@ Middleware<AppState> _createLoadState(
completer.future.then((_) {
final layout = calculateLayout(action.context);
if (store.state.prefState.isNotMobile && layout == AppLayout.mobile) {
print('## View dashboard');
store.dispatch(UpdateUserPreferences(appLayout: layout));
AppBuilder.of(action.context).rebuild();
WidgetsBinding.instance.addPostFrameCallback((duration) {