From 50373001a9935d86db67b11cfd6abb1240ee26bc Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 3 Jan 2019 14:46:20 -0500 Subject: [PATCH] add fetchSilently param for doFetchUser --- dist/bundle.js | 11 ++++++++++- src/redux/actions/user.js | 40 ++++++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/dist/bundle.js b/dist/bundle.js index 71d8bce..f7af4fa 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -8680,8 +8680,17 @@ function doAuthenticate(appVersion) { }; } -function doUserFetch() { +function doUserFetch(fetchSilently) { return function (dispatch) { + // If we are doing this in the background, do not set loading = true + if (fetchSilently) { + return _lbryio2.default.getCurrentUser().then(function (user) { + dispatch({ + type: _lbryRedux.ACTIONS.USER_FETCH_SUCCESS, + data: { user: user } + }); + }); + } dispatch({ type: _lbryRedux.ACTIONS.USER_FETCH_STARTED }); diff --git a/src/redux/actions/user.js b/src/redux/actions/user.js index ec1054d..a07fe75 100644 --- a/src/redux/actions/user.js +++ b/src/redux/actions/user.js @@ -74,27 +74,37 @@ export function doAuthenticate(appVersion, os = null) { }; } -export function doUserFetch() { +export function doUserFetch(fetchSilently) { return dispatch => { - dispatch({ - type: ACTIONS.USER_FETCH_STARTED, - }); - Lbryio.getCurrentUser() - .then(user => { - // analytics.setUser(user); - dispatch(doRewardList()); - + // If we are doing this in the background, do not set loading = true + if (fetchSilently) { + Lbryio.getCurrentUser().then(user => { dispatch({ type: ACTIONS.USER_FETCH_SUCCESS, data: { user }, }); - }) - .catch(error => { - dispatch({ - type: ACTIONS.USER_FETCH_FAILURE, - data: { error }, - }); }); + } else { + dispatch({ + type: ACTIONS.USER_FETCH_STARTED, + }); + Lbryio.getCurrentUser() + .then(user => { + // analytics.setUser(user); + dispatch(doRewardList()); + + dispatch({ + type: ACTIONS.USER_FETCH_SUCCESS, + data: { user }, + }); + }) + .catch(error => { + dispatch({ + type: ACTIONS.USER_FETCH_FAILURE, + data: { error }, + }); + }); + } }; }