Fix crash when opening links

This commit fixes the issue where opening links while browsing would trigger an account switch with a null name.
This commit is contained in:
Balazs Toldi 2024-07-29 21:47:48 +02:00
parent de92e0edd3
commit 4ccb1a38bf

View File

@ -224,7 +224,7 @@ public class LinkResolverActivity extends AppCompatActivity {
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else {
if (mAccountQualifedName == null || !mAccountQualifedName.equals(newAccountName)) {
if (mAccountQualifedName == null || newAccountName != null && !mAccountQualifedName.equals(newAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mRetrofit, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), newAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
@ -259,7 +259,7 @@ public class LinkResolverActivity extends AppCompatActivity {
}
});
} else {
if (mAccountQualifedName == null || !mAccountQualifedName.equals(newAccountName)) {
if (mAccountQualifedName == null || newAccountName != null && !mAccountQualifedName.equals(newAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mRetrofit, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), newAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));