From 31299530d0404b928689b59a0fb0ca56d369096a Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 29 Oct 2019 15:14:41 -0400 Subject: [PATCH] add bad password action --- dist/bundle.es.js | 21 ++++++++++++++++++++- dist/bundle.js | 27 ++++++++++++++++++++++++++- src/constants/action_types.js | 1 + src/index.js | 1 + src/redux/actions/sync.js | 7 +++++++ src/redux/reducers/sync.js | 7 +++++++ src/redux/selectors/sync.js | 5 +++++ 7 files changed, 67 insertions(+), 2 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index bb5142e..a9cee32 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -129,6 +129,7 @@ const SET_DEFAULT_ACCOUNT = 'SET_DEFAULT_ACCOUNT'; const SYNC_APPLY_STARTED = 'SYNC_APPLY_STARTED'; const SYNC_APPLY_COMPLETED = 'SYNC_APPLY_COMPLETED'; const SYNC_APPLY_FAILED = 'SYNC_APPLY_FAILED'; +const SYNC_APPLY_BAD_PASSWORD = 'SYNC_APPLY_BAD_PASSWORD'; const SYNC_RESET = 'SYNC_RESET'; // Lbry.tv const UPDATE_UPLOAD_PROGRESS = 'UPDATE_UPLOAD_PROGRESS'; @@ -247,6 +248,7 @@ var action_types = /*#__PURE__*/Object.freeze({ SYNC_APPLY_STARTED: SYNC_APPLY_STARTED, SYNC_APPLY_COMPLETED: SYNC_APPLY_COMPLETED, SYNC_APPLY_FAILED: SYNC_APPLY_FAILED, + SYNC_APPLY_BAD_PASSWORD: SYNC_APPLY_BAD_PASSWORD, SYNC_RESET: SYNC_RESET, UPDATE_UPLOAD_PROGRESS: UPDATE_UPLOAD_PROGRESS }); @@ -2490,7 +2492,16 @@ function doGetSync(passedPassword, callback) { data: { error } - }); + }); // Temp solution until we have a bad password error code + // Don't fail on blank passwords so we don't show a "password error" message + // before users have ever entered a password + + if (password !== '') { + dispatch({ + type: SYNC_APPLY_BAD_PASSWORD + }); + } + handleCallback(error); } else { // user doesn't have a synced wallet @@ -3192,6 +3203,7 @@ const defaultState$9 = { getSyncErrorMessage: null, syncApplyErrorMessage: '', syncApplyIsPending: false, + syncApplyPasswordError: false, getSyncIsPending: false, setSyncIsPending: false, hashChanged: false @@ -3234,6 +3246,7 @@ reducers$3[SET_SYNC_COMPLETED] = (state, action) => Object.assign({}, state, { }); reducers$3[SYNC_APPLY_STARTED] = state => Object.assign({}, state, { + syncApplyPasswordError: false, syncApplyIsPending: true, syncApplyErrorMessage: '' }); @@ -3248,6 +3261,10 @@ reducers$3[SYNC_APPLY_FAILED] = (state, action) => Object.assign({}, state, { syncApplyErrorMessage: action.data.error }); +reducers$3[SYNC_APPLY_BAD_PASSWORD] = state => Object.assign({}, state, { + syncApplyPasswordError: true +}); + reducers$3[SYNC_RESET] = () => defaultState$9; function syncReducer(state = defaultState$9, action) { @@ -3354,6 +3371,7 @@ const selectSetSyncIsPending = reselect.createSelector(selectState$9, state => s const selectHashChanged = reselect.createSelector(selectState$9, state => state.hashChanged); const selectSyncApplyIsPending = reselect.createSelector(selectState$9, state => state.syncApplyIsPending); const selectSyncApplyErrorMessage = reselect.createSelector(selectState$9, state => state.syncApplyErrorMessage); +const selectSyncApplyPasswordError = reselect.createSelector(selectState$9, state => state.syncApplyPasswordError); const selectState$a = state => state.lbrytv || {}; @@ -3489,6 +3507,7 @@ exports.selectSuggested = selectSuggested; exports.selectSuggestedChannels = selectSuggestedChannels; exports.selectSyncApplyErrorMessage = selectSyncApplyErrorMessage; exports.selectSyncApplyIsPending = selectSyncApplyIsPending; +exports.selectSyncApplyPasswordError = selectSyncApplyPasswordError; exports.selectSyncData = selectSyncData; exports.selectSyncHash = selectSyncHash; exports.selectTrendingUris = selectTrendingUris; diff --git a/dist/bundle.js b/dist/bundle.js index f2612e3..28c8db5 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -461,6 +461,8 @@ __webpack_require__.r(__webpack_exports__); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "selectSyncApplyErrorMessage", function() { return redux_selectors_sync__WEBPACK_IMPORTED_MODULE_36__["selectSyncApplyErrorMessage"]; }); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "selectSyncApplyPasswordError", function() { return redux_selectors_sync__WEBPACK_IMPORTED_MODULE_36__["selectSyncApplyPasswordError"]; }); + /* harmony import */ var redux_selectors_lbrytv__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(47); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "selectCurrentUploads", function() { return redux_selectors_lbrytv__WEBPACK_IMPORTED_MODULE_37__["selectCurrentUploads"]; }); @@ -633,6 +635,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SYNC_APPLY_STARTED", function() { return SYNC_APPLY_STARTED; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SYNC_APPLY_COMPLETED", function() { return SYNC_APPLY_COMPLETED; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SYNC_APPLY_FAILED", function() { return SYNC_APPLY_FAILED; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SYNC_APPLY_BAD_PASSWORD", function() { return SYNC_APPLY_BAD_PASSWORD; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SYNC_RESET", function() { return SYNC_RESET; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UPDATE_UPLOAD_PROGRESS", function() { return UPDATE_UPLOAD_PROGRESS; }); // User @@ -756,6 +759,7 @@ var SET_DEFAULT_ACCOUNT = 'SET_DEFAULT_ACCOUNT'; var SYNC_APPLY_STARTED = 'SYNC_APPLY_STARTED'; var SYNC_APPLY_COMPLETED = 'SYNC_APPLY_COMPLETED'; var SYNC_APPLY_FAILED = 'SYNC_APPLY_FAILED'; +var SYNC_APPLY_BAD_PASSWORD = 'SYNC_APPLY_BAD_PASSWORD'; var SYNC_RESET = 'SYNC_RESET'; // Lbry.tv var UPDATE_UPLOAD_PROGRESS = 'UPDATE_UPLOAD_PROGRESS'; @@ -4084,7 +4088,16 @@ function doGetSync(passedPassword, callback) { data: { error: error } - }); + }); // Temp solution until we have a bad password error code + // Don't fail on blank passwords so we don't show a "password error" message + // before users have ever entered a password + + if (password !== '') { + dispatch({ + type: constants_action_types__WEBPACK_IMPORTED_MODULE_0__["SYNC_APPLY_BAD_PASSWORD"] + }); + } + handleCallback(error); } else { // user doesn't have a synced wallet @@ -4985,6 +4998,7 @@ var defaultState = { getSyncErrorMessage: null, syncApplyErrorMessage: '', syncApplyIsPending: false, + syncApplyPasswordError: false, getSyncIsPending: false, setSyncIsPending: false, hashChanged: false @@ -5040,6 +5054,7 @@ reducers[constants_action_types__WEBPACK_IMPORTED_MODULE_0__["SET_SYNC_COMPLETED reducers[constants_action_types__WEBPACK_IMPORTED_MODULE_0__["SYNC_APPLY_STARTED"]] = function (state) { return Object.assign({}, state, { + syncApplyPasswordError: false, syncApplyIsPending: true, syncApplyErrorMessage: '' }); @@ -5059,6 +5074,12 @@ reducers[constants_action_types__WEBPACK_IMPORTED_MODULE_0__["SYNC_APPLY_FAILED" }); }; +reducers[constants_action_types__WEBPACK_IMPORTED_MODULE_0__["SYNC_APPLY_BAD_PASSWORD"]] = function (state) { + return Object.assign({}, state, { + syncApplyPasswordError: true + }); +}; + reducers[constants_action_types__WEBPACK_IMPORTED_MODULE_0__["SYNC_RESET"]] = function () { return defaultState; }; @@ -5317,6 +5338,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectHashChanged", function() { return selectHashChanged; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectSyncApplyIsPending", function() { return selectSyncApplyIsPending; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectSyncApplyErrorMessage", function() { return selectSyncApplyErrorMessage; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectSyncApplyPasswordError", function() { return selectSyncApplyPasswordError; }); /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14); /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(reselect__WEBPACK_IMPORTED_MODULE_0__); @@ -5355,6 +5377,9 @@ var selectSyncApplyIsPending = Object(reselect__WEBPACK_IMPORTED_MODULE_0__["cre var selectSyncApplyErrorMessage = Object(reselect__WEBPACK_IMPORTED_MODULE_0__["createSelector"])(selectState, function (state) { return state.syncApplyErrorMessage; }); +var selectSyncApplyPasswordError = Object(reselect__WEBPACK_IMPORTED_MODULE_0__["createSelector"])(selectState, function (state) { + return state.syncApplyPasswordError; +}); /***/ }), /* 47 */ diff --git a/src/constants/action_types.js b/src/constants/action_types.js index 9f8b3f5..45b759f 100644 --- a/src/constants/action_types.js +++ b/src/constants/action_types.js @@ -128,6 +128,7 @@ export const SET_DEFAULT_ACCOUNT = 'SET_DEFAULT_ACCOUNT'; export const SYNC_APPLY_STARTED = 'SYNC_APPLY_STARTED'; export const SYNC_APPLY_COMPLETED = 'SYNC_APPLY_COMPLETED'; export const SYNC_APPLY_FAILED = 'SYNC_APPLY_FAILED'; +export const SYNC_APPLY_BAD_PASSWORD = 'SYNC_APPLY_BAD_PASSWORD'; export const SYNC_RESET = 'SYNC_RESET'; // Lbry.tv diff --git a/src/index.js b/src/index.js index 6647ac4..e3e8d24 100644 --- a/src/index.js +++ b/src/index.js @@ -191,5 +191,6 @@ export { selectSyncApplyIsPending, selectHashChanged, selectSyncApplyErrorMessage, + selectSyncApplyPasswordError, } from 'redux/selectors/sync'; export { selectCurrentUploads, selectUploadCount } from 'redux/selectors/lbrytv'; diff --git a/src/redux/actions/sync.js b/src/redux/actions/sync.js index 95dfd44..bd24d83 100644 --- a/src/redux/actions/sync.js +++ b/src/redux/actions/sync.js @@ -142,6 +142,13 @@ export function doGetSync(passedPassword, callback) { }, }); + // Temp solution until we have a bad password error code + // Don't fail on blank passwords so we don't show a "password error" message + // before users have ever entered a password + if (password !== '') { + dispatch({ type: ACTIONS.SYNC_APPLY_BAD_PASSWORD }); + } + handleCallback(error); } else { // user doesn't have a synced wallet diff --git a/src/redux/reducers/sync.js b/src/redux/reducers/sync.js index 47ca138..497e581 100644 --- a/src/redux/reducers/sync.js +++ b/src/redux/reducers/sync.js @@ -9,6 +9,7 @@ const defaultState = { getSyncErrorMessage: null, syncApplyErrorMessage: '', syncApplyIsPending: false, + syncApplyPasswordError: false, getSyncIsPending: false, setSyncIsPending: false, hashChanged: false, @@ -57,6 +58,7 @@ reducers[ACTIONS.SET_SYNC_COMPLETED] = (state, action) => reducers[ACTIONS.SYNC_APPLY_STARTED] = state => Object.assign({}, state, { + syncApplyPasswordError: false, syncApplyIsPending: true, syncApplyErrorMessage: '', }); @@ -73,6 +75,11 @@ reducers[ACTIONS.SYNC_APPLY_FAILED] = (state, action) => syncApplyErrorMessage: action.data.error, }); +reducers[ACTIONS.SYNC_APPLY_BAD_PASSWORD] = state => + Object.assign({}, state, { + syncApplyPasswordError: true, + }); + reducers[ACTIONS.SYNC_RESET] = () => defaultState; export function syncReducer(state = defaultState, action) { diff --git a/src/redux/selectors/sync.js b/src/redux/selectors/sync.js index 811e025..4448c6c 100644 --- a/src/redux/selectors/sync.js +++ b/src/redux/selectors/sync.js @@ -33,3 +33,8 @@ export const selectSyncApplyErrorMessage = createSelector( selectState, state => state.syncApplyErrorMessage ); + +export const selectSyncApplyPasswordError = createSelector( + selectState, + state => state.syncApplyPasswordError +);