Fix token checking (again)

Failure to call the API (e.g. network error) with the token caused incorrect relogin requests.
This commit is contained in:
Bazsalanszky 2024-07-25 10:42:41 +02:00
parent ae74eeba0f
commit f5b8206959
No known key found for this signature in database
GPG Key ID: B40814F4EFE23F96
3 changed files with 9 additions and 1 deletions

View File

@ -54,6 +54,7 @@ import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.navigation.NavigationView;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import com.google.android.material.textfield.TextInputEditText;
@ -1113,6 +1114,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
.setCancelable(false)
.show();
}
@Override
public void onCheckFailed(String message) {
applySnackBarTheme(Snackbar.make(findViewById(android.R.id.content), getString(R.string.failed_to_check_token_validity,message), Snackbar.LENGTH_LONG)).show();
}
});
}
}

View File

@ -124,7 +124,7 @@ public class FetchUserData {
@Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
validateAuthTokenListener.onValidateAuthTokenFailed();
validateAuthTokenListener.onCheckFailed(t.getMessage());
}
});
}
@ -133,6 +133,7 @@ public class FetchUserData {
void onValidateAuthTokenSuccess();
void onValidateAuthTokenFailed();
void onCheckFailed(String message);
}
public interface FetchUserUnreadCountListener {

View File

@ -1334,4 +1334,5 @@
<string name="settings_dont_hide_your_own_read_posts_automatically">Don\'t hide your own read posts automatically</string>
<string name="deleted_by_creator">deleted by creator</string>
<string name="removed_by_moderator">removed by moderator</string>
<string name="failed_to_check_token_validity">Failed to check token validity: %s</string>
</resources>