Correct deleting primary company

This commit is contained in:
Hillel Coren 2021-03-26 14:45:53 +03:00
parent 838c592737
commit 30c4e6ab3e
2 changed files with 11 additions and 4 deletions

View File

@ -213,9 +213,14 @@ Middleware<AppState> _createRefreshRequest(AuthRepository repository) {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
final url = final url =
formatApiUrl(prefs.getString(kSharedPrefUrl) ?? state.authState.url); formatApiUrl(prefs.getString(kSharedPrefUrl) ?? state.authState.url);
final token =
TokenEntity.unobscureToken(prefs.getString(kSharedPrefToken)) ?? String token;
if ((state?.userCompany?.token?.token ?? '').isNotEmpty) {
token = state.userCompany.token.token;
} else {
token = TokenEntity.unobscureToken(prefs.getString(kSharedPrefToken)) ??
'TOKEN'; 'TOKEN';
}
final updatedAt = action.clearData && !company.isLarge final updatedAt = action.clearData && !company.isLarge
? 0 ? 0

View File

@ -72,7 +72,9 @@ class AccountManagementVM {
GoogleOAuth.disconnect(); GoogleOAuth.disconnect();
} }
} else { } else {
store.dispatch(SelectCompany(companyIndex: 0)); final selectedCompanyIndex = state.uiState.selectedCompanyIndex;
final index = selectedCompanyIndex == 0 ? 1 : 0;
store.dispatch(SelectCompany(companyIndex: index));
final refreshCompleter = Completer<Null>() final refreshCompleter = Completer<Null>()
..future.then((value) { ..future.then((value) {
store.dispatch(SelectCompany(companyIndex: 0)); store.dispatch(SelectCompany(companyIndex: 0));