avoid sessions without instance info
This commit is contained in:
parent
31d22bac47
commit
c80afaf9c0
|
@ -52,6 +52,12 @@ public class MainActivity extends FragmentStackActivity{
|
|||
}else{
|
||||
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());
|
||||
Fragment fragment=session.activated ? new HomeFragment() : new AccountActivationFragment();
|
||||
fragment.setArguments(args);
|
||||
|
|
|
@ -110,6 +110,12 @@ public class AccountSessionManager{
|
|||
sessions.put(session.getID(), session);
|
||||
lastActiveAccountID=session.getID();
|
||||
writeAccountsFile();
|
||||
|
||||
// write initial instance info to file immediately to avoid sessions without instance info
|
||||
InstanceInfoStorageWrapper wrapper = new InstanceInfoStorageWrapper();
|
||||
wrapper.instance = instance;
|
||||
MastodonAPIController.runInBackground(()->writeInstanceInfoFile(wrapper, instance.uri));
|
||||
|
||||
updateMoreInstanceInfo(instance, instance.uri);
|
||||
if(PushSubscriptionManager.arePushNotificationsAvailable()){
|
||||
session.getPushSubscriptionManager().registerAccountForPush(null);
|
||||
|
|
Loading…
Reference in New Issue