Merge pull request #15 from lbryio/modals

Strip out modal code
This commit is contained in:
Sean Yesmunt 2018-11-28 18:23:20 -05:00 committed by GitHub
commit 50da4e2efd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 68 deletions

67
dist/bundle.js vendored
View file

@ -4116,11 +4116,11 @@ var selectAllClaimsByChannel = exports.selectAllClaimsByChannel = (0, _reselect.
});
var selectPendingById = exports.selectPendingById = (0, _reselect.createSelector)(selectState, function (state) {
return state.pendingById || {};
return state.pendingById;
});
var selectPendingClaims = exports.selectPendingClaims = (0, _reselect.createSelector)(selectState, function (state) {
return Object.values(state.pendingById || []);
return Object.values(state.pendingById || {});
});
var makeSelectClaimIsPending = exports.makeSelectClaimIsPending = function makeSelectClaimIsPending(uri) {
@ -6130,8 +6130,7 @@ exports.formatCredits = formatCredits;
exports.formatFullPrice = formatFullPrice;
exports.creditsToString = creditsToString;
function formatCredits(amount, precision) {
if (Number.isNaN(parseFloat(amount))) return '0';
return parseFloat(amount).toFixed(precision || 1).replace(/\.?0+$/, '');
return amount.toFixed(precision || 1).replace(/\.?0+$/, '');
}
function formatFullPrice(amount) {
@ -6257,13 +6256,13 @@ reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = function (state, action) {
var byId = Object.assign({}, state.byId);
var pendingById = Object.assign({}, state.pendingById);
claims.forEach(function (claim) {
if (claim.type && claim.type.match(/claim|update/)) {
if (claim.confirmations < 1) {
pendingById[claim.claim_id] = claim;
} else {
byId[claim.claim_id] = claim;
}
claims.filter(function (claim) {
return claim.type && claim.type.match(/claim|update/);
}).forEach(function (claim) {
if (claim.confirmations < 1) {
pendingById[claim.claim_id] = claim;
} else {
byId[claim.claim_id] = claim;
}
});
@ -7928,12 +7927,8 @@ function doClaimRewardType(rewardType) {
}
if (!userIsRewardApproved && rewardType !== _rewards3.default.TYPE_CONFIRM_EMAIL) {
if (!options || !options.failSilently) {
var action = (0, _lbryRedux.doNotify)({
id: _lbryRedux.MODALS.REWARD_APPROVAL_REQUIRED,
isError: false
});
dispatch(action);
if (!options || !options.failSilently && _rewards3.default.callbacks.rewardApprovalRequested) {
_rewards3.default.callbacks.rewardApprovalRequested();
}
return;
@ -7951,13 +7946,8 @@ function doClaimRewardType(rewardType) {
reward: successReward
}
});
if (successReward.reward_type === _rewards3.default.TYPE_NEW_USER) {
var _action = (0, _lbryRedux.doNotify)({
message: 'You just earned your first reward!',
id: _lbryRedux.MODALS.FIRST_REWARD,
isError: false
});
dispatch(_action);
if (successReward.reward_type === _rewards3.default.TYPE_NEW_USER && _rewards3.default.callbacks.claimFirstRewardSuccess) {
_rewards3.default.callbacks.claimFirstRewardSuccess();
}
dispatch(doRewardList());
@ -8439,18 +8429,11 @@ rewards.claimReward = function (type, rewardParams) {
_lbryio2.default.call('reward', 'new', params, 'post').then(function (reward) {
var message = reward.reward_notification || 'You have claimed a ' + reward.reward_amount + ' LBC reward.';
// We use a modal in the desktop app for this reward code. Dismiss it before showing the snackbar
if (type === rewards.TYPE_REWARD_CODE) {
window.store.dispatch((0, _lbryRedux.doHideNotification)());
}
// Display global notice
var action = (0, _lbryRedux.doNotify)({
var action = (0, _lbryRedux.doToast)({
message: message,
linkText: __('Show All'),
linkTarget: '/rewards',
isError: false,
displayType: ['snackbar']
linkTarget: '/rewards'
});
window.store.dispatch(action);
@ -8505,6 +8488,18 @@ rewards.claimReward = function (type, rewardParams) {
});
};
rewards.callbacks = {
// Set any callbacks that require code not found in this project
// claimRewardSuccess: null,
// claimRewardError: null,
claimFirstRewardSuccess: null,
rewardApprovalRequired: null
};
rewards.setCallback = function (name, method) {
rewards.callbacks[name] = method;
};
exports.default = rewards;
/***/ }),
@ -8597,6 +8592,7 @@ function doAuthenticate(appVersion) {
dispatch({
type: _lbryRedux.ACTIONS.AUTHENTICATION_STARTED
});
_lbryio2.default.authenticate().then(function (user) {
// analytics.setUser(user);
dispatch({
@ -8607,7 +8603,6 @@ function doAuthenticate(appVersion) {
dispatch(doFetchInviteStatus());
doInstallNew(appVersion, os);
}).catch(function (error) {
dispatch((0, _lbryRedux.doNotify)({ id: _lbryRedux.MODALS.AUTHENTICATION_FAILURE }));
dispatch({
type: _lbryRedux.ACTIONS.AUTHENTICATION_FAILURE,
data: { error: error }
@ -8696,7 +8691,6 @@ function doUserPhoneVerify(verificationCode) {
type: _lbryRedux.ACTIONS.USER_PHONE_VERIFY_SUCCESS,
data: { user: user }
});
dispatch((0, _lbryRedux.doHideNotification)());
dispatch((0, _rewards.doClaimRewardType)(_rewards3.default.TYPE_NEW_USER));
}
}).catch(function (error) {
@ -8862,8 +8856,7 @@ function doUserInviteNew(email) {
data: { email: email }
});
dispatch((0, _lbryRedux.doNotify)({
displayType: ['snackbar'],
dispatch((0, _lbryRedux.doToast)({
message: __('Invite sent to %s', email)
}));

View file

@ -28,7 +28,7 @@
"format": "prettier 'src/**/*.{js,json}' --write"
},
"dependencies": {
"lbry-redux": "lbryio/lbry-redux#2375860d6269d0369418879c2531b1d48c4e47f2",
"lbry-redux": "lbryio/lbry-redux#1ed2ea8b2de99bbcba652aa7b00478d02df4a290",
"reselect": "^3.0.0"
},
"devDependencies": {

View file

@ -1,5 +1,5 @@
import Lbryio from 'lbryio';
import { doNotify, ACTIONS, MODALS } from 'lbry-redux';
import { ACTIONS } from 'lbry-redux';
import { selectUnclaimedRewards } from 'redux/selectors/rewards';
import { selectUserIsRewardApproved } from 'redux/selectors/user';
import rewards from 'rewards';
@ -44,12 +44,8 @@ export function doClaimRewardType(rewardType, options = {}) {
}
if (!userIsRewardApproved && rewardType !== rewards.TYPE_CONFIRM_EMAIL) {
if (!options || !options.failSilently) {
const action = doNotify({
id: MODALS.REWARD_APPROVAL_REQUIRED,
isError: false,
});
dispatch(action);
if (!options || (!options.failSilently && rewards.callbacks.rewardApprovalRequested)) {
rewards.callbacks.rewardApprovalRequested();
}
return;
@ -67,13 +63,11 @@ export function doClaimRewardType(rewardType, options = {}) {
reward: successReward,
},
});
if (successReward.reward_type === rewards.TYPE_NEW_USER) {
const action = doNotify({
message: 'You just earned your first reward!',
id: MODALS.FIRST_REWARD,
isError: false,
});
dispatch(action);
if (
successReward.reward_type === rewards.TYPE_NEW_USER &&
rewards.callbacks.claimFirstRewardSuccess
) {
rewards.callbacks.claimFirstRewardSuccess();
}
dispatch(doRewardList());

View file

@ -1,4 +1,4 @@
import { ACTIONS, MODALS, Lbry, doNotify, doHideNotification } from 'lbry-redux';
import { ACTIONS, Lbry, doToast } from 'lbry-redux';
import { doClaimRewardType, doRewardList } from 'redux/actions/rewards';
import {
selectEmailToVerify,
@ -53,6 +53,7 @@ export function doAuthenticate(appVersion, os = null) {
dispatch({
type: ACTIONS.AUTHENTICATION_STARTED,
});
Lbryio.authenticate()
.then(user => {
// analytics.setUser(user);
@ -65,7 +66,6 @@ export function doAuthenticate(appVersion, os = null) {
doInstallNew(appVersion, os);
})
.catch(error => {
dispatch(doNotify({ id: MODALS.AUTHENTICATION_FAILURE }));
dispatch({
type: ACTIONS.AUTHENTICATION_FAILURE,
data: { error },
@ -167,7 +167,6 @@ export function doUserPhoneVerify(verificationCode) {
type: ACTIONS.USER_PHONE_VERIFY_SUCCESS,
data: { user },
});
dispatch(doHideNotification());
dispatch(doClaimRewardType(rewards.TYPE_NEW_USER));
}
})
@ -349,8 +348,7 @@ export function doUserInviteNew(email) {
});
dispatch(
doNotify({
displayType: ['snackbar'],
doToast({
message: __('Invite sent to %s', email),
})
);

View file

@ -1,4 +1,4 @@
import { Lbry, doNotify, doHideNotification } from 'lbry-redux';
import { Lbry, doToast } from 'lbry-redux';
import Lbryio from 'lbryio';
const rewards = {};
@ -27,18 +27,11 @@ rewards.claimReward = (type, rewardParams) => {
const message =
reward.reward_notification || `You have claimed a ${reward.reward_amount} LBC reward.`;
// We use a modal in the desktop app for this reward code. Dismiss it before showing the snackbar
if (type === rewards.TYPE_REWARD_CODE) {
window.store.dispatch(doHideNotification());
}
// Display global notice
const action = doNotify({
const action = doToast({
message,
linkText: __('Show All'),
linkTarget: '/rewards',
isError: false,
displayType: ['snackbar'],
});
window.store.dispatch(action);
@ -114,4 +107,16 @@ rewards.claimReward = (type, rewardParams) => {
});
};
rewards.callbacks = {
// Set any callbacks that require code not found in this project
// claimRewardSuccess: null,
// claimRewardError: null,
claimFirstRewardSuccess: null,
rewardApprovalRequired: null,
};
rewards.setCallback = (name, method) => {
rewards.callbacks[name] = method;
};
export default rewards;

View file

@ -3358,9 +3358,9 @@ kind-of@^6.0.0, kind-of@^6.0.2:
version "6.0.2"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051"
lbry-redux@lbryio/lbry-redux#2375860d6269d0369418879c2531b1d48c4e47f2:
lbry-redux@lbryio/lbry-redux#9a20637926970b239bb08083c9027fac340ce82b:
version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/2375860d6269d0369418879c2531b1d48c4e47f2"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/9a20637926970b239bb08083c9027fac340ce82b"
dependencies:
proxy-polyfill "0.1.6"
reselect "^3.0.0"