Skip to content

Commit d19f162

Browse files
committed
performance: skipping another useless HTTP request.
1 parent 9c9bb99 commit d19f162

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

mobile/src/main/java/io/syslogic/github/network/TokenHelper.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,16 @@ public class TokenHelper {
4343
@Nullable
4444
public static String getAccessToken(@NonNull Context context) {
4545
AccountManager accountManager = AccountManager.get(context);
46-
if (mDebug) {
47-
/* Attempting to load the personal access token from package meta. */
46+
Account account = getAccount(accountManager, 0);
47+
if (account != null) {
48+
/* Default: Load the access token from AccountManager. */
49+
return accountManager.getUserData(account, "token");
50+
} else if (mDebug) {
51+
/* Debug: Try to load and validate the access token. */
4852
return loadTokenFromPackageMeta(context, accountManager);
4953
} else {
50-
/* Attempting to load the personal access token from AccountManager. */
51-
Account account = getAccount(accountManager, 0);
52-
if (account != null) {
53-
return accountManager.getUserData(account, "token");
54-
} else {
55-
Log.e(LOG_TAG, "account not found: " + Constants.ACCOUNT_TYPE);
56-
return null;
57-
}
54+
Log.e(LOG_TAG, "Account not found: " + Constants.ACCOUNT_TYPE);
55+
return null;
5856
}
5957
}
6058

0 commit comments

Comments
 (0)