From 3a2ae1ce715aab684e9e2485cb12ea543427c74e Mon Sep 17 00:00:00 2001 From: sk Date: Mon, 29 May 2023 02:40:15 +0200 Subject: [PATCH] clean up preferences when removing account --- .../joinmastodon/android/GlobalUserPreferences.java | 11 ++++++++++- .../android/api/session/AccountSessionManager.java | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index 1e0960e12..d789d321d 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -77,6 +77,16 @@ public class GlobalUserPreferences{ catch (JsonSyntaxException ignored) { return orElse; } } + public static void removeAccount(String accountId) { + recentLanguages.remove(accountId); + pinnedTimelines.remove(accountId); + accountsInGlitchMode.remove(accountId); + accountsWithLocalOnlySupport.remove(accountId); + accountsWithContentTypesEnabled.remove(accountId); + accountsDefaultContentTypes.remove(accountId); + save(); + } + public static void load(){ SharedPreferences prefs=getPrefs(); playGifs=prefs.getBoolean("playGifs", true); @@ -186,4 +196,3 @@ public class GlobalUserPreferences{ DARK } } - diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java index 2589f7fa9..d746661f4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java @@ -15,6 +15,7 @@ import android.util.Log; import org.joinmastodon.android.BuildConfig; import org.joinmastodon.android.E; +import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.MainActivity; import org.joinmastodon.android.MastodonApp; import org.joinmastodon.android.R; @@ -184,6 +185,7 @@ public class AccountSessionManager{ AccountSession session=getAccount(id); session.getCacheController().closeDatabase(); MastodonApp.context.deleteDatabase(id+".db"); + GlobalUserPreferences.removeAccount(id); sessions.remove(id); if(lastActiveAccountID.equals(id)){ if(sessions.isEmpty())