diff --git a/package.json b/package.json index fe026d736..82edf72ca 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "hast-util-sanitize": "^1.1.2", "keytar": "^4.2.1", "lbry-redux": "lbryio/lbry-redux#1ed2ea8b2de99bbcba652aa7b00478d02df4a290", - "lbryinc": "lbryio/lbryinc#e9508e259fa9bce3b69915b91534516cf5937075", + "lbryinc": "lbryio/lbryinc#7b578e7ff49aef384f27533cd666c53873ddc8d9", "localforage": "^1.7.1", "mammoth": "^1.4.6", "mime": "^2.3.1", diff --git a/src/renderer/index.js b/src/renderer/index.js index 1a14d13b2..e88246e19 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -5,15 +5,21 @@ import SnackBar from 'component/snackBar'; import SplashScreen from 'component/splash'; import moment from 'moment'; import * as ACTIONS from 'constants/action_types'; +import * as MODALS from 'constants/modal_types'; import { ipcRenderer, remote, shell } from 'electron'; import React from 'react'; import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; -import { doConditionalAuthNavigate, doDaemonReady, doAutoUpdate } from 'redux/actions/app'; +import { + doConditionalAuthNavigate, + doDaemonReady, + doAutoUpdate, + doOpenModal, +} from 'redux/actions/app'; import { doToast, doBlackListedOutpointsSubscribe, isURIValid } from 'lbry-redux'; import { doNavigate } from 'redux/actions/navigation'; import { doDownloadLanguages, doUpdateIsNightAsync } from 'redux/actions/settings'; -import { doUserEmailVerify, doAuthenticate, Lbryio } from 'lbryinc'; +import { doUserEmailVerify, doAuthenticate, Lbryio, rewards } from 'lbryinc'; import 'scss/all.scss'; import store from 'store'; import pjson from 'package.json'; @@ -60,6 +66,14 @@ Lbryio.setOverride( }) ); +rewards.setCallback('claimFirstRewardSuccess', () => { + app.store.dispatch(doOpenModal(MODALS.FIRST_REWARD)); +}); + +rewards.setCallback('rewardApprovalRequired', () => { + app.store.dispatch(doOpenModal(MODALS.REWARD_APPROVAL_REQUIRED)); +}); + ipcRenderer.on('open-uri-requested', (event, uri, newSession) => { if (uri && uri.startsWith('lbry://')) { if (uri.startsWith('lbry://?verify=')) { diff --git a/src/renderer/modal/modalRouter/index.js b/src/renderer/modal/modalRouter/index.js index e9f18c7a3..673316518 100644 --- a/src/renderer/modal/modalRouter/index.js +++ b/src/renderer/modal/modalRouter/index.js @@ -5,12 +5,12 @@ import { selectBalance, selectCurrentPage, selectError, - doToast + doToast, } from 'lbry-redux'; import { makeSelectClientSetting } from 'redux/selectors/settings'; import { selectUser, selectUserIsVerificationCandidate } from 'lbryinc'; import { selectModal } from 'redux/selectors/app'; - +import { doOpenModal } from 'redux/actions/app'; import ModalRouter from './view'; const select = state => ({ @@ -30,6 +30,7 @@ const select = state => ({ const perform = dispatch => ({ showToast: props => dispatch(doToast(props)), + openModal: props => dispatch(doOpenModal(props)), }); export default connect( diff --git a/src/renderer/redux/actions/app.js b/src/renderer/redux/actions/app.js index 03251bd08..beeeb6dd7 100644 --- a/src/renderer/redux/actions/app.js +++ b/src/renderer/redux/actions/app.js @@ -364,9 +364,9 @@ export function doClickCommentButton() { export function doConditionalAuthNavigate(newSession) { return (dispatch, getState) => { const state = getState(); - const notification = selectModal(state); + const modal = selectModal(state); - if (newSession || (notification && notification.id !== 'email_collection')) { + if (newSession || (modal && modal.id !== MODALS.EMAIL_COLLECTION)) { dispatch(doAuthNavigate()); } }; diff --git a/src/renderer/redux/reducers/app.js b/src/renderer/redux/reducers/app.js index 295c852b0..f92652d07 100644 --- a/src/renderer/redux/reducers/app.js +++ b/src/renderer/redux/reducers/app.js @@ -1,7 +1,7 @@ // @flow import * as ACTIONS from 'constants/action_types'; - +import * as MODALS from 'constants/modal_types'; import { remote } from 'electron'; const win = remote.BrowserWindow.getFocusedWindow(); @@ -196,14 +196,22 @@ reducers[ACTIONS.ADD_COMMENT] = state => reducers[ACTIONS.SHOW_MODAL] = (state, action) => Object.assign({}, state, { modal: action.data.id, - modalProps: action.data.modalProps - }) + modalProps: action.data.modalProps, + }); -reducers[ACTIONS.HIDE_MODAL] = (state, action) => +reducers[ACTIONS.HIDE_MODAL] = state => Object.assign({}, state, { modal: null, modalProps: null, - }) + }); + +// This is fired from the lbryinc module +// Instead of adding callbacks in that module, we can just listen for this event +// There will be no other modals at this time as this is a blocking action +reducers[ACTIONS.AUTHENTICATION_FAILURE] = state => + Object.assign({}, state, { + modal: MODALS.AUTHENTICATION_FAILURE, + }); export default function reducer(state: AppState = defaultState, action: any) { const handler = reducers[action.type]; diff --git a/yarn.lock b/yarn.lock index c82742cf9..6103dd792 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5669,20 +5669,12 @@ lbry-redux@lbryio/lbry-redux#1ed2ea8b2de99bbcba652aa7b00478d02df4a290: dependencies: proxy-polyfill "0.1.6" reselect "^3.0.0" - uuid "^3.3.2" -lbry-redux@lbryio/lbry-redux#2375860d6269d0369418879c2531b1d48c4e47f2: +lbryinc@lbryio/lbryinc#7b578e7ff49aef384f27533cd666c53873ddc8d9: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/2375860d6269d0369418879c2531b1d48c4e47f2" + resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/7b578e7ff49aef384f27533cd666c53873ddc8d9" dependencies: - proxy-polyfill "0.1.6" - reselect "^3.0.0" - -lbryinc@lbryio/lbryinc#e9508e259fa9bce3b69915b91534516cf5937075: - version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/e9508e259fa9bce3b69915b91534516cf5937075" - dependencies: - lbry-redux lbryio/lbry-redux#2375860d6269d0369418879c2531b1d48c4e47f2 + lbry-redux lbryio/lbry-redux#1ed2ea8b2de99bbcba652aa7b00478d02df4a290 reselect "^3.0.0" lcid@^1.0.0: