From bd88606c48b6c010e89c6f70e6e4eb5d0f471f8f Mon Sep 17 00:00:00 2001 From: FineFindus Date: Thu, 13 Jun 2024 19:22:45 +0200 Subject: [PATCH] fix(AccountSwitcherSheet): only restart on different accounts Changes the AccountSwitcherSheet from always restarting the application to only restarting if a different account is selected. This reduces the friction of accidentally clicking on the same account. --- .../joinmastodon/android/ui/sheets/AccountSwitcherSheet.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/AccountSwitcherSheet.java b/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/AccountSwitcherSheet.java index 460db1ec1..55cf1eb1d 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/AccountSwitcherSheet.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/AccountSwitcherSheet.java @@ -35,6 +35,7 @@ import org.joinmastodon.android.ui.views.CheckableRelativeLayout; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.function.BiConsumer; import java.util.stream.Collectors; @@ -338,7 +339,8 @@ public class AccountSwitcherSheet extends BottomSheet{ onClick.accept(item.getID(), false); return; } - if(AccountSessionManager.getInstance().tryGetAccount(item.getID())!=null){ + AccountSessionManager accountSessionManager=AccountSessionManager.getInstance(); + if(accountSessionManager.tryGetAccount(item.getID())!=null && !Objects.equals(accountSessionManager.getLastActiveAccountID(), item.getID())){ AccountSessionManager.getInstance().setLastActiveAccountID(item.getID()); ((MainActivity)activity).restartActivity(); }