From 34bae6a5df04238675c4a51110d6780aeca41af1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 11 Apr 2020 18:55:07 -0500 Subject: [PATCH] Skip verify_credentials if there are no credentials --- app/gabsocial/actions/me.js | 3 +++ app/gabsocial/reducers/me.js | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/gabsocial/actions/me.js b/app/gabsocial/actions/me.js index 0925fcf40..8d9b806b2 100644 --- a/app/gabsocial/actions/me.js +++ b/app/gabsocial/actions/me.js @@ -4,9 +4,12 @@ import { importFetchedAccount } from './importer'; export const ME_FETCH_REQUEST = 'ME_FETCH_REQUEST'; export const ME_FETCH_SUCCESS = 'ME_FETCH_SUCCESS'; export const ME_FETCH_FAIL = 'ME_FETCH_FAIL'; +export const ME_FETCH_SKIP = 'ME_FETCH_SKIP'; export function fetchMe() { return (dispatch, getState) => { + const accessToken = getState().getIn(['auth', 'user', 'access_token']); + if (!accessToken) return dispatch({type: ME_FETCH_SKIP}); dispatch(fetchMeRequest()); api(getState).get(`/api/v1/accounts/verify_credentials`).then(response => { dispatch(fetchMeSuccess(response.data)); diff --git a/app/gabsocial/reducers/me.js b/app/gabsocial/reducers/me.js index 6f52a7164..fa377c3bc 100644 --- a/app/gabsocial/reducers/me.js +++ b/app/gabsocial/reducers/me.js @@ -1,4 +1,4 @@ -import { ME_FETCH_SUCCESS, ME_FETCH_FAIL } from '../actions/me'; +import { ME_FETCH_SUCCESS, ME_FETCH_FAIL, ME_FETCH_SKIP } from '../actions/me'; import { AUTH_LOGGED_OUT } from '../actions/auth'; import { Map as ImmutableMap, fromJS } from 'immutable'; @@ -10,6 +10,8 @@ export default function me(state = initialState, action) { return fromJS(action.me.id); case ME_FETCH_FAIL: return false; + case ME_FETCH_SKIP: + return false; case AUTH_LOGGED_OUT: return false; default: