mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-10-25 14:15:48 +03:00
Fix TokenMismatchException after deleting and readding an account
This commit is contained in:
parent
4df11459d5
commit
027f787003
2 changed files with 34 additions and 2 deletions
|
@ -810,10 +810,10 @@ public class NotesDatabase extends AbstractNotesDatabase {
|
|||
}
|
||||
|
||||
try {
|
||||
NotesClient.invalidateAPICache(AccountImporter.getSingleSignOnAccount(getContext(), localAccount.getAccountName()));
|
||||
SSOClient.invalidateAPICache(AccountImporter.getSingleSignOnAccount(getContext(), localAccount.getAccountName()));
|
||||
} catch (NextcloudFilesAppAccountNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
NotesClient.invalidateAPICache();
|
||||
SSOClient.invalidateAPICache();
|
||||
}
|
||||
|
||||
final int deletedNotes = db.delete(table_notes, key_account_id + " = ?", new String[]{String.valueOf(localAccount.getId())});
|
||||
|
|
|
@ -47,4 +47,36 @@ public class SSOClient {
|
|||
return nextcloudAPI;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates thes API cache for the given ssoAccount
|
||||
*
|
||||
* @param ssoAccount the ssoAccount for which the API cache should be cleared.
|
||||
*/
|
||||
public static void invalidateAPICache(@NonNull SingleSignOnAccount ssoAccount) {
|
||||
Log.v(TAG, "Invalidating API cache for " + ssoAccount.name);
|
||||
if (mNextcloudAPIs.containsKey(ssoAccount.name)) {
|
||||
final NextcloudAPI nextcloudAPI = mNextcloudAPIs.get(ssoAccount.name);
|
||||
if (nextcloudAPI != null) {
|
||||
nextcloudAPI.stop();
|
||||
}
|
||||
mNextcloudAPIs.remove(ssoAccount.name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates the whole API cache for all accounts
|
||||
*/
|
||||
public static void invalidateAPICache() {
|
||||
for (String key : mNextcloudAPIs.keySet()) {
|
||||
Log.v(TAG, "Invalidating API cache for " + key);
|
||||
if (mNextcloudAPIs.containsKey(key)) {
|
||||
final NextcloudAPI nextcloudAPI = mNextcloudAPIs.get(key);
|
||||
if (nextcloudAPI != null) {
|
||||
nextcloudAPI.stop();
|
||||
}
|
||||
mNextcloudAPIs.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue