From de7bc2de08bb82d666cf92f9e462de4c33d487ad Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Sat, 13 Jan 2024 00:21:23 -0500 Subject: Fix inserting the anonymous account even when it was already inserted. --- .../ml/docilealligator/infinityforreddit/AccessTokenAuthenticator.java | 2 +- .../infinityforreddit/ApplicationOnlyAccessTokenAuthenticator.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AccessTokenAuthenticator.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AccessTokenAuthenticator.java index 19e6d0da..f8da226a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AccessTokenAuthenticator.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AccessTokenAuthenticator.java @@ -49,7 +49,7 @@ class AccessTokenAuthenticator implements Authenticator { Account account = mRedditDataRoomDatabase.accountDao().getCurrentAccount(); if (account == null) { //Anonymous mode - if (mRedditDataRoomDatabase.accountDao().isAnonymousAccountInserted()) { + if (!mRedditDataRoomDatabase.accountDao().isAnonymousAccountInserted()) { mRedditDataRoomDatabase.accountDao().insert(Account.getAnonymousAccount()); } String accessTokenFromSharedPreference = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, ""); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ApplicationOnlyAccessTokenAuthenticator.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ApplicationOnlyAccessTokenAuthenticator.java index 75f0ed13..970b81fd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ApplicationOnlyAccessTokenAuthenticator.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ApplicationOnlyAccessTokenAuthenticator.java @@ -46,7 +46,7 @@ class ApplicationOnlyAccessTokenAuthenticator implements Authenticator { String accessToken = accessTokenHeader.substring(APIUtils.AUTHORIZATION_BASE.length()); synchronized (this) { - if (mRedditDataRoomDatabase.accountDao().isAnonymousAccountInserted()) { + if (!mRedditDataRoomDatabase.accountDao().isAnonymousAccountInserted()) { mRedditDataRoomDatabase.accountDao().insert(Account.getAnonymousAccount()); } String accessTokenFromSharedPreference = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, ""); -- cgit v1.2.3