Fix 401 error when adding a new account

This commit is contained in:
Shinokuni 2020-07-26 14:24:31 +02:00
parent 5e1e16b10e
commit 0d00f8db0b

View File

@ -577,12 +577,16 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
Account newAccount = data.getParcelableExtra(ACCOUNT);
if (newAccount != null) {
viewModel.addAccount(newAccount);
// get credentials before creating the repository
if (!newAccount.isLocal()) {
getAccountCredentials(Collections.singletonList(newAccount));
}
viewModel.addAccount(newAccount);
adapter.clearData();
// start syncing only if the account is not local
if (!viewModel.isAccountLocal()) {
getAccountCredentials(Collections.singletonList(newAccount));
refreshLayout.setRefreshing(true);
onRefresh();
}