diff --git a/app/package-lock.json b/app/package-lock.json index fc54fa68..ffcf8e98 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -3982,19 +3982,37 @@ } }, "lbry-redux": { - "version": "github:lbryio/lbry-redux#30af6b5483fd74d66082316c621b761853d1419a", - "from": "github:lbryio/lbry-redux#pre-notification-update", + "version": "github:lbryio/lbry-redux#1ed2ea8b2de99bbcba652aa7b00478d02df4a290", + "from": "github:lbryio/lbry-redux", "requires": { "proxy-polyfill": "0.1.6", - "reselect": "^3.0.0" + "reselect": "^3.0.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + } } }, "lbryinc": { - "version": "github:lbryio/lbryinc#ef0fd224a2ed2863a8b512207d46f149747d3e68", - "from": "github:lbryio/lbryinc#daemon-0.30.1-rc", + "version": "github:lbryio/lbryinc#82308ece97188747adbf6d71d55b6e7a6fa0bd95", + "from": "github:lbryio/lbryinc", "requires": { - "lbry-redux": "github:lbryio/lbry-redux#30af6b5483fd74d66082316c621b761853d1419a", + "lbry-redux": "github:lbryio/lbry-redux#2375860d6269d0369418879c2531b1d48c4e47f2", "reselect": "^3.0.0" + }, + "dependencies": { + "lbry-redux": { + "version": "github:lbryio/lbry-redux#2375860d6269d0369418879c2531b1d48c4e47f2", + "from": "github:lbryio/lbry-redux#2375860d6269d0369418879c2531b1d48c4e47f2", + "requires": { + "proxy-polyfill": "0.1.6", + "reselect": "^3.0.0" + } + } } }, "lcid": { diff --git a/app/package.json b/app/package.json index f1d48afa..3e0a86e2 100644 --- a/app/package.json +++ b/app/package.json @@ -7,8 +7,8 @@ }, "dependencies": { "base-64": "^0.1.0", - "lbry-redux": "lbryio/lbry-redux#pre-notification-update", - "lbryinc": "lbryio/lbryinc#daemon-0.30.1-rc", + "lbry-redux": "lbryio/lbry-redux", + "lbryinc": "lbryio/lbryinc", "moment": "^2.22.1", "react": "16.2.0", "react-native": "0.55.3", diff --git a/app/src/component/AppNavigator.js b/app/src/component/AppNavigator.js index 2efe153b..92bc1e60 100644 --- a/app/src/component/AppNavigator.js +++ b/app/src/component/AppNavigator.js @@ -33,7 +33,7 @@ import { ToastAndroid } from 'react-native'; import { doDeleteCompleteBlobs } from '../redux/actions/file'; -import { SETTINGS, doHideNotification, doNotify, selectNotification } from 'lbry-redux'; +import { SETTINGS, doDismissToast, doToast, selectToast } from 'lbry-redux'; import { doUserEmailVerify, doUserEmailVerifyFailure, @@ -240,28 +240,16 @@ class AppWithNavigationState extends React.Component { componentWillUpdate(nextProps) { const { dispatch } = this.props; const { - notification, + toast, emailToVerify, emailVerifyPending, emailVerifyErrorMessage, user } = nextProps; - if (notification) { - const { displayType, message } = notification; + if (toast) { + const { message } = toast; let currentDisplayType; - if (displayType && displayType.length) { - for (let i = 0; i < displayType.length; i++) { - const type = displayType[i]; - if (AppWithNavigationState.supportedDisplayTypes.indexOf(type) > -1) { - currentDisplayType = type; - break; - } - } - } else if (AppWithNavigationState.supportedDisplayTypes.indexOf(displayType) > -1) { - currentDisplayType = displayType; - } - if (!currentDisplayType && message) { // default to toast if no display type set and there is a message specified currentDisplayType = 'toast'; @@ -271,7 +259,7 @@ class AppWithNavigationState extends React.Component { ToastAndroid.show(message, ToastAndroid.LONG); } - dispatch(doHideNotification()); + dispatch(doDismissToast()); } if (user && @@ -287,7 +275,7 @@ class AppWithNavigationState extends React.Component { AsyncStorage.removeItem(Constants.KEY_FIRST_RUN_EMAIL); } AsyncStorage.removeItem(Constants.KEY_SHOULD_VERIFY_EMAIL); - dispatch(doNotify({ message, displayType: ['toast'] })); + dispatch(doToast({ message })); } }); } @@ -340,12 +328,11 @@ class AppWithNavigationState extends React.Component { } catch (error) { const message = 'Invalid Verification Token'; dispatch(doUserEmailVerifyFailure(message)); - dispatch(doNotify({ message, displayType: ['toast'] })); + dispatch(doToast({ message })); } } else { - dispatch(doNotify({ + dispatch(doToast({ message: 'Invalid Verification URI', - displayType: ['toast'], })); } } else { @@ -363,7 +350,7 @@ const mapStateToProps = state => ({ backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state), keepDaemonRunning: makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING)(state), nav: state.nav, - notification: selectNotification(state), + toast: selectToast(state), emailToVerify: selectEmailToVerify(state), emailVerifyPending: selectEmailVerifyIsPending(state), emailVerifyErrorMessage: selectEmailVerifyErrorMessage(state), diff --git a/app/src/component/address/index.js b/app/src/component/address/index.js index 9aaa4a3b..fea1b6ce 100644 --- a/app/src/component/address/index.js +++ b/app/src/component/address/index.js @@ -1,7 +1,7 @@ import { connect } from 'react-redux'; -import { doNotify } from 'lbry-redux'; +import { doToast } from 'lbry-redux'; import Address from './view'; export default connect(null, { - doNotify, + doToast, })(Address); diff --git a/app/src/component/address/view.js b/app/src/component/address/view.js index 1730dd27..6562bb39 100644 --- a/app/src/component/address/view.js +++ b/app/src/component/address/view.js @@ -6,21 +6,20 @@ import walletStyle from '../../styles/wallet'; type Props = { address: string, - doNotify: ({ message: string, displayType: Array<string> }) => void, + doToast: ({ message: string }) => void, }; export default class Address extends React.PureComponent<Props> { render() { - const { address, doNotify, style } = this.props; - + const { address, doToast, style } = this.props; + return ( <View style={[walletStyle.row, style]}> <Text selectable={true} numberOfLines={1} style={walletStyle.address}>{address || ''}</Text> <Button icon={'clipboard'} style={walletStyle.button} onPress={() => { Clipboard.setString(address); - doNotify({ + doToast({ message: 'Address copied', - displayType: ['toast'], }); }} /> </View> diff --git a/app/src/component/emailRewardSubcard/index.js b/app/src/component/emailRewardSubcard/index.js index 55998604..b4941ce9 100644 --- a/app/src/component/emailRewardSubcard/index.js +++ b/app/src/component/emailRewardSubcard/index.js @@ -5,7 +5,7 @@ import { selectEmailNewIsPending, selectEmailToVerify } from 'lbryinc'; -import { doNotify } from 'lbry-redux'; +import { doToast } from 'lbry-redux'; import EmailRewardSubcard from './view'; const select = state => ({ @@ -16,7 +16,7 @@ const select = state => ({ const perform = dispatch => ({ addUserEmail: email => dispatch(doUserEmailNew(email)), - notify: data => dispatch(doNotify(data)) + notify: data => dispatch(doToast(data)) }); -export default connect(select, perform)(EmailRewardSubcard); \ No newline at end of file +export default connect(select, perform)(EmailRewardSubcard); diff --git a/app/src/component/emailRewardSubcard/view.js b/app/src/component/emailRewardSubcard/view.js index c43242fd..fe3ee652 100644 --- a/app/src/component/emailRewardSubcard/view.js +++ b/app/src/component/emailRewardSubcard/view.js @@ -38,12 +38,11 @@ class EmailRewardSubcard extends React.PureComponent { if (this.state.verifyStarted && !emailNewPending) { if (emailNewErrorMessage) { - notify({ message: String(emailNewErrorMessage), displayType: ['toast']}); + notify({ message: String(emailNewErrorMessage), isError: true }); this.setState({ verifyStarted: false }); } else { notify({ message: 'Please follow the instructions in the email sent to your address to continue.', - displayType: ['toast'] }); } } @@ -65,7 +64,6 @@ class EmailRewardSubcard extends React.PureComponent { if (!email || email.trim().length === 0 || email.indexOf('@') === -1) { return notify({ message: 'Please provide a valid email address to continue.', - displayType: ['toast'], }); } diff --git a/app/src/component/link/index.js b/app/src/component/link/index.js index 8c06e44b..05ccefed 100644 --- a/app/src/component/link/index.js +++ b/app/src/component/link/index.js @@ -1,9 +1,9 @@ import { connect } from 'react-redux'; -import { doNotify } from 'lbry-redux'; +import { doToast } from 'lbry-redux'; import Link from './view'; const perform = dispatch => ({ - notify: (data) => dispatch(doNotify(data)) + notify: (data) => dispatch(doToast(data)) }); export default connect(null, perform)(Link); diff --git a/app/src/component/link/view.js b/app/src/component/link/view.js index 86dc4148..d0d73487 100644 --- a/app/src/component/link/view.js +++ b/app/src/component/link/view.js @@ -21,7 +21,7 @@ export default class Link extends React.PureComponent { Linking.openURL(href) .then(() => setTimeout(() => { this.setState({ tappedStyle: false }); }, 2000)) .catch(err => { - notify({ message: error, displayType: ['toast']}) + notify({ message: error, isError: true }) this.setState({tappedStyle: false}) } ); diff --git a/app/src/component/phoneNumberRewardSubcard/index.js b/app/src/component/phoneNumberRewardSubcard/index.js index a9bd9866..55873318 100644 --- a/app/src/component/phoneNumberRewardSubcard/index.js +++ b/app/src/component/phoneNumberRewardSubcard/index.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux'; -import { doNotify } from 'lbry-redux'; +import { doToast } from 'lbry-redux'; import { doUserPhoneNew, doUserPhoneVerify, @@ -22,7 +22,7 @@ const select = state => ({ const perform = dispatch => ({ addUserPhone: (phone, country_code) => dispatch(doUserPhoneNew(phone, country_code)), verifyPhone: (verificationCode) => dispatch(doUserPhoneVerify(verificationCode)), - notify: data => dispatch(doNotify(data)), + notify: data => dispatch(doToast(data)), }); -export default connect(select, perform)(PhoneNumberRewardSubcard); \ No newline at end of file +export default connect(select, perform)(PhoneNumberRewardSubcard); diff --git a/app/src/component/phoneNumberRewardSubcard/view.js b/app/src/component/phoneNumberRewardSubcard/view.js index 7856c4fb..2cb841fb 100644 --- a/app/src/component/phoneNumberRewardSubcard/view.js +++ b/app/src/component/phoneNumberRewardSubcard/view.js @@ -70,17 +70,17 @@ class PhoneNumberRewardSubcard extends React.PureComponent { if (!phoneNewIsPending && (phoneNewIsPending !== prevProps.phoneNewIsPending)) { if (phoneNewErrorMessage) { - notify({ message: String(phoneNewErrorMessage), displayType: ['toast'] }); + notify({ message: String(phoneNewErrorMessage) }); } else { this.setState({ newPhoneAdded: true }); } } if (!phoneVerifyIsPending && (phoneVerifyIsPending !== prevProps.phoneVerifyIsPending)) { if (phoneVerifyErrorMessage) { - notify({ message: String(phoneVerifyErrorMessage), displayType: ['toast'] }); + notify({ message: String(phoneVerifyErrorMessage) }); this.setState({ codeVerifyStarted: false }); } else { - notify({ message: 'Your phone number was successfully verified.', displayType: ['toast'] }); + notify({ message: 'Your phone number was successfully verified.' }); this.setState({ codeVerifySuccessful: true }); if (onPhoneVerifySuccessful) { onPhoneVerifySuccessful(); @@ -107,7 +107,6 @@ class PhoneNumberRewardSubcard extends React.PureComponent { if (!NativeModules.UtilityModule) { return notify({ message: 'The required permission could not be obtained due to a missing module.', - displayType: ['toast'] }); } @@ -120,7 +119,6 @@ class PhoneNumberRewardSubcard extends React.PureComponent { if (!this.phoneInput.isValidNumber()) { return notify({ message: 'Please provide a valid telephone number.', - displayType: ['toast'] }); } diff --git a/app/src/component/rewardCard/index.js b/app/src/component/rewardCard/index.js index c0ea7e1c..eea39cf5 100644 --- a/app/src/component/rewardCard/index.js +++ b/app/src/component/rewardCard/index.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux'; -import { doNotify } from 'lbry-redux'; +import { doToast } from 'lbry-redux'; import { doClaimRewardType, doClaimRewardClearError, @@ -23,7 +23,7 @@ const makeSelect = () => { const perform = dispatch => ({ claimReward: reward => dispatch(doClaimRewardType(reward.reward_type, true)), clearError: reward => dispatch(doClaimRewardClearError(reward)), - notify: data => dispatch(doNotify(data)) + notify: data => dispatch(doToast(data)) }); export default connect(makeSelect, perform)(RewardCard); diff --git a/app/src/component/rewardCard/view.js b/app/src/component/rewardCard/view.js index 7182d4e2..18679852 100644 --- a/app/src/component/rewardCard/view.js +++ b/app/src/component/rewardCard/view.js @@ -30,10 +30,10 @@ class RewardCard extends React.PureComponent<Props> { const { clearError, notify, reward } = this.props; if (this.state.claimStarted && !isPending) { if (errorMessage && errorMessage.trim().length > 0) { - notify({ message: errorMessage, displayType: ['toast'] }); + notify({ message: errorMessage }); clearError(reward); } else { - notify({ message: 'Reward successfully claimed!', displayType: ['toast'] }); + notify({ message: 'Reward successfully claimed!' }); } this.setState({ claimStarted: false }); } @@ -48,7 +48,7 @@ class RewardCard extends React.PureComponent<Props> { } = this.props; if (!canClaim) { - notify({ message: 'Unfortunately, you are not eligible to claim this reward at this time.', displayType: ['toast'] }); + notify({ message: 'Unfortunately, you are not eligible to claim this reward at this time.' }); return; } diff --git a/app/src/component/rewardSummary/index.js b/app/src/component/rewardSummary/index.js index 5c2a7077..482c88ba 100644 --- a/app/src/component/rewardSummary/index.js +++ b/app/src/component/rewardSummary/index.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux'; -import { doNotify } from 'lbry-redux'; +import { doToast } from 'lbry-redux'; import { doRewardList, selectUnclaimedRewardValue, selectFetchingRewards, selectUser } from 'lbryinc'; import RewardSummary from './view'; @@ -11,7 +11,7 @@ const select = state => ({ const perform = dispatch => ({ fetchRewards: () => dispatch(doRewardList()), - notify: data => dispatch(doNotify(data)) + notify: data => dispatch(doToast(data)) }); export default connect(select, perform)(RewardSummary); diff --git a/app/src/component/rewardSummary/view.js b/app/src/component/rewardSummary/view.js index cbdf50d2..9adf6e55 100644 --- a/app/src/component/rewardSummary/view.js +++ b/app/src/component/rewardSummary/view.js @@ -38,7 +38,6 @@ class RewardSummary extends React.Component { this.setState({ dismissed: true }); this.props.notify({ message: 'You can always claim your rewards from the Rewards page.', - displayType: ['toast'] }); } diff --git a/app/src/component/walletSend/index.js b/app/src/component/walletSend/index.js index d334f64b..e57233ea 100644 --- a/app/src/component/walletSend/index.js +++ b/app/src/component/walletSend/index.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux'; import { - doNotify, + doToast, doSendDraftTransaction, selectDraftTransaction, selectDraftTransactionError, @@ -10,7 +10,7 @@ import WalletSend from './view'; const perform = dispatch => ({ sendToAddress: (address, amount) => dispatch(doSendDraftTransaction(address, amount)), - notify: (data) => dispatch(doNotify(data)) + notify: (data) => dispatch(doToast(data)) }); const select = state => ({ diff --git a/app/src/component/walletSend/view.js b/app/src/component/walletSend/view.js index 7e79d152..cf74a586 100644 --- a/app/src/component/walletSend/view.js +++ b/app/src/component/walletSend/view.js @@ -38,7 +38,6 @@ class WalletSend extends React.PureComponent<Props> { if (address && !regexAddress.test(address)) { notify({ message: 'The recipient address is not a valid LBRY address.', - displayType: ['toast'] }); return; } @@ -46,7 +45,6 @@ class WalletSend extends React.PureComponent<Props> { if (amount > balance) { notify({ message: 'Insufficient credits', - displayType: ['toast'] }); return; } @@ -71,7 +69,6 @@ class WalletSend extends React.PureComponent<Props> { const { notify } = this.props; notify({ message: 'The recipient address is not a valid LBRY address.', - displayType: ['toast'] }); } } diff --git a/app/src/page/file/index.js b/app/src/page/file/index.js index d909afb5..36256b1b 100644 --- a/app/src/page/file/index.js +++ b/app/src/page/file/index.js @@ -3,7 +3,7 @@ import { doFetchFileInfo, doFetchCostInfoForUri, doResolveUri, - doNotify, + doToast, makeSelectIsUriResolving, makeSelectCostInfoForUri, makeSelectFileInfoForUri, @@ -38,7 +38,7 @@ const perform = dispatch => ({ }, fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)), fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)), - notify: data => dispatch(doNotify(data)), + notify: data => dispatch(doToast(data)), resolveUri: uri => dispatch(doResolveUri(uri)), stopDownload: (uri, fileInfo) => dispatch(doStopDownloadingFile(uri, fileInfo)), }); diff --git a/app/src/page/file/view.js b/app/src/page/file/view.js index c617c6ea..b6f2d928 100644 --- a/app/src/page/file/view.js +++ b/app/src/page/file/view.js @@ -189,7 +189,6 @@ class FilePage extends React.PureComponent { // after the file_set_status and file_delete operations, so let the user know notify({ message: 'The download will stop momentarily. You do not need to wait to discover something else.', - displayType: ['toast'] }); }} ], diff --git a/app/src/page/firstRun/index.js b/app/src/page/firstRun/index.js index 14ad9603..c196505e 100644 --- a/app/src/page/firstRun/index.js +++ b/app/src/page/firstRun/index.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux'; -import { doNotify } from 'lbry-redux'; +import { doToast } from 'lbry-redux'; import { doGenerateAuthToken, doUserEmailNew, @@ -22,7 +22,7 @@ const select = (state) => ({ const perform = dispatch => ({ addUserEmail: email => dispatch(doUserEmailNew(email)), generateAuthToken: installationId => dispatch(doGenerateAuthToken(installationId)), - notify: data => dispatch(doNotify(data)) + notify: data => dispatch(doToast(data)) }); -export default connect(select, perform)(FirstRun); \ No newline at end of file +export default connect(select, perform)(FirstRun); diff --git a/app/src/page/firstRun/view.js b/app/src/page/firstRun/view.js index f169cbde..7fba3ad7 100644 --- a/app/src/page/firstRun/view.js +++ b/app/src/page/firstRun/view.js @@ -61,7 +61,7 @@ class FirstRunScreen extends React.PureComponent { if (this.state.emailSubmitted && !emailNewPending) { this.setState({ emailSubmitted: false }); if (emailNewErrorMessage) { - notify ({ message: String(emailNewErrorMessage), displayType: ['toast']}); + notify ({ message: String(emailNewErrorMessage), isError: true }); } else { // Request successful. Navigate to discover. this.closeFinalPage(); @@ -115,7 +115,6 @@ class FirstRunScreen extends React.PureComponent { if (email.indexOf('@') === -1) { return notify({ message: 'Please provide a valid email address to continue.', - displayType: ['toast'], }); } diff --git a/app/src/page/rewards/index.js b/app/src/page/rewards/index.js index 89fbcc43..b9138fdd 100644 --- a/app/src/page/rewards/index.js +++ b/app/src/page/rewards/index.js @@ -8,7 +8,7 @@ import { selectClaimedRewards, selectUser, } from 'lbryinc'; -import { doNotify } from 'lbry-redux'; +import { doToast } from 'lbry-redux'; import RewardsPage from './view'; const select = state => ({ @@ -22,7 +22,7 @@ const select = state => ({ const perform = dispatch => ({ fetchRewards: () => dispatch(doRewardList()), - notify: data => dispatch(doNotify(data)), + notify: data => dispatch(doToast(data)), }); -export default connect(select, perform)(RewardsPage); \ No newline at end of file +export default connect(select, perform)(RewardsPage); diff --git a/app/src/page/splash/index.js b/app/src/page/splash/index.js index 2116937a..a7829409 100644 --- a/app/src/page/splash/index.js +++ b/app/src/page/splash/index.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux'; -import { doBalanceSubscribe, doBlackListedOutpointsSubscribe, doNotify } from 'lbry-redux'; +import { doBalanceSubscribe, doBlackListedOutpointsSubscribe, doToast } from 'lbry-redux'; import { doAuthenticate, doFetchRewardedContent, @@ -23,7 +23,7 @@ const perform = dispatch => ({ blacklistedOutpointsSubscribe: () => dispatch(doBlackListedOutpointsSubscribe()), deleteCompleteBlobs: () => dispatch(doDeleteCompleteBlobs()), fetchRewardedContent: () => dispatch(doFetchRewardedContent()), - notify: data => dispatch(doNotify(data)), + notify: data => dispatch(doToast(data)), setEmailToVerify: email => dispatch(doUserEmailToVerify(email)), verifyUserEmail: (token, recaptcha) => dispatch(doUserEmailVerify(token, recaptcha)), verifyUserEmailFailure: error => dispatch(doUserEmailVerifyFailure(error)), diff --git a/app/src/page/splash/view.js b/app/src/page/splash/view.js index e1acafbd..56b17f37 100644 --- a/app/src/page/splash/view.js +++ b/app/src/page/splash/view.js @@ -102,12 +102,11 @@ class SplashScreen extends React.PureComponent { } catch (error) { const message = 'Invalid Verification Token'; verifyUserEmailFailure(message); - notify({ message, displayType: ['toast'] }); + notify({ message }); } } else { notify({ message: 'Invalid Verification URI', - displayType: ['toast'], }); } } else { diff --git a/app/src/redux/actions/file.js b/app/src/redux/actions/file.js index d7806fd3..661a490a 100644 --- a/app/src/redux/actions/file.js +++ b/app/src/redux/actions/file.js @@ -1,7 +1,7 @@ import { ACTIONS, Lbry, - doNotify, + doToast, formatCredits, selectBalance, makeSelectCostInfoForUri, @@ -190,9 +190,8 @@ export function doLoadVideo(uri, failureCallback) { data: { uri }, }); - dispatch(doNotify({ + dispatch(doToast({ message: `File timeout for uri ${uri}`, - displayType: ['toast'] })); if (failureCallback) { @@ -209,9 +208,8 @@ export function doLoadVideo(uri, failureCallback) { data: { uri }, }); - dispatch(doNotify({ + dispatch(doToast({ message: `Failed to download ${uri}, please try again. If this problem persists, visit https://lbry.io/faq/support for support.`, - displayType: ['toast'] })); if (failureCallback) { @@ -270,9 +268,8 @@ export function doPurchaseUri(uri, specificCostInfo, failureCallback) { if (cost > balance) { dispatch(doSetPlayingUri(null)); - dispatch(doNotify({ + dispatch(doToast({ message: 'Insufficient credits', - displayType: ['toast'] })); if (failureCallback) { failureCallback();