throw exception if no instance for session

This commit is contained in:
sk 2023-05-29 13:31:42 +02:00
parent 7849c34d1f
commit 32081b71f5
2 changed files with 6 additions and 7 deletions

View File

@ -52,12 +52,6 @@ public class MainActivity extends FragmentStackActivity{
}else{ }else{
session=AccountSessionManager.getInstance().getLastActiveAccount(); session=AccountSessionManager.getInstance().getLastActiveAccount();
} }
if (session.getInstance() == null) {
// i don't know how, but i ended up having a session, but no instance info.
// removing account to avoid glitched behavior and crashes
AccountSessionManager.getInstance().removeAccount(session.getID());
session=AccountSessionManager.getInstance().getLastActiveAccount();
}
args.putString("account", session.getID()); args.putString("account", session.getID());
Fragment fragment=session.activated ? new HomeFragment() : new AccountActivationFragment(); Fragment fragment=session.activated ? new HomeFragment() : new AccountActivationFragment();
fragment.setArguments(args); fragment.setArguments(args);

View File

@ -463,7 +463,12 @@ public class AccountSessionManager{
} }
public Instance getInstanceInfo(String domain){ public Instance getInstanceInfo(String domain){
return instances.get(domain); Instance instance = instances.get(domain);
if (instance == null) {
throw new IllegalStateException("Cannot get instance for " + domain + ". Sessions: "
+ String.join(", ", instances.keySet()));
}
return instance;
} }
public void updateAccountInfo(String id, Account account){ public void updateAccountInfo(String id, Account account){