custom reward toast messages

This commit is contained in:
jessop 2019-10-20 13:23:20 -04:00
parent aebad10a9c
commit 32136f5bc0
3 changed files with 170 additions and 15 deletions

70
dist/bundle.es.js vendored
View file

@ -482,6 +482,61 @@ rewards.YOUTUBE_CREATOR = 'youtube_creator';
rewards.TYPE_DAILY_VIEW = 'daily_view';
rewards.claimReward = (type, rewardParams) => {
let reason;
switch (type) {
case rewards.TYPE_NEW_DEVELOPER:
reason = __('for being a new developer!');
break;
case rewards.TYPE_NEW_USER:
reason = __('for being a new user!');
break;
case rewards.TYPE_CONFIRM_EMAIL:
reason = __('for confirming your email!');
break;
case rewards.TYPE_FIRST_CHANNEL:
reason = __('for your first channel!');
break;
case rewards.TYPE_FIRST_STREAM:
reason = __('for your first publish!');
break;
case rewards.TYPE_MANY_DOWNLOADS:
reason = __('for having many downloads!');
break;
case rewards.TYPE_FIRST_PUBLISH:
reason = __('for your first publish!');
break;
case rewards.TYPE_REFERRAL:
reason = __('for a referral!');
break;
case rewards.TYPE_REWARD_CODE:
reason = __('for entering a reward code!');
break;
case rewards.TYPE_SUBSCRIPTION:
reason = __('for adding a subscription!');
break;
case rewards.YOUTUBE_CREATOR:
reason = __('for being a youtube creator!');
break;
case rewards.TYPE_DAILY_VIEW:
reason = __('for viewing content today!');
break;
default:
reason = '.';
}
function requestReward(resolve, reject, params) {
if (!Lbryio.enabled) {
reject(new Error(__('Rewards are not enabled.')));
@ -489,7 +544,8 @@ rewards.claimReward = (type, rewardParams) => {
}
Lbryio.call('reward', 'new', params, 'post').then(reward => {
const message = reward.reward_notification || `You have claimed a ${reward.reward_amount} LBC reward.`; // Display global notice
// different message per type
const message = reward.reward_notification || `You have claimed a ${reward.reward_amount} LBC reward ${reason}`; // Display global notice
const action = lbryRedux.doToast({
message,
@ -2455,13 +2511,13 @@ function doGetSync(passedPassword, callback) {
handleCallback();
}
});
} else {
dispatch({
type: GET_SYNC_COMPLETED,
data
});
handleCallback();
}
dispatch({
type: GET_SYNC_COMPLETED,
data
});
handleCallback();
}).catch(() => {
if (data.hasSyncedWallet) {
const error = 'Error getting synced wallet';

70
dist/bundle.js vendored
View file

@ -1225,6 +1225,61 @@ rewards.YOUTUBE_CREATOR = 'youtube_creator';
rewards.TYPE_DAILY_VIEW = 'daily_view';
rewards.claimReward = function (type, rewardParams) {
var reason;
switch (type) {
case rewards.TYPE_NEW_DEVELOPER:
reason = __('for being a new developer!');
break;
case rewards.TYPE_NEW_USER:
reason = __('for being a new user!');
break;
case rewards.TYPE_CONFIRM_EMAIL:
reason = __('for confirming your email!');
break;
case rewards.TYPE_FIRST_CHANNEL:
reason = __('for your first channel!');
break;
case rewards.TYPE_FIRST_STREAM:
reason = __('for your first publish!');
break;
case rewards.TYPE_MANY_DOWNLOADS:
reason = __('for having many downloads!');
break;
case rewards.TYPE_FIRST_PUBLISH:
reason = __('for your first publish!');
break;
case rewards.TYPE_REFERRAL:
reason = __('for a referral!');
break;
case rewards.TYPE_REWARD_CODE:
reason = __('for entering a reward code!');
break;
case rewards.TYPE_SUBSCRIPTION:
reason = __('for adding a subscription!');
break;
case rewards.YOUTUBE_CREATOR:
reason = __('for being a youtube creator!');
break;
case rewards.TYPE_DAILY_VIEW:
reason = __('for viewing content today!');
break;
default:
reason = '.';
}
function requestReward(resolve, reject, params) {
if (!lbryio__WEBPACK_IMPORTED_MODULE_1__["default"].enabled) {
reject(new Error(__('Rewards are not enabled.')));
@ -1232,7 +1287,8 @@ rewards.claimReward = function (type, rewardParams) {
}
lbryio__WEBPACK_IMPORTED_MODULE_1__["default"].call('reward', 'new', params, 'post').then(function (reward) {
var message = reward.reward_notification || "You have claimed a ".concat(reward.reward_amount, " LBC reward."); // Display global notice
// different message per type
var message = reward.reward_notification || "You have claimed a ".concat(reward.reward_amount, " LBC reward ").concat(reason); // Display global notice
var action = Object(lbry_redux__WEBPACK_IMPORTED_MODULE_0__["doToast"])({
message: message,
@ -4019,13 +4075,13 @@ function doGetSync(passedPassword, callback) {
handleCallback();
}
});
} else {
dispatch({
type: constants_action_types__WEBPACK_IMPORTED_MODULE_0__["GET_SYNC_COMPLETED"],
data: data
});
handleCallback();
}
dispatch({
type: constants_action_types__WEBPACK_IMPORTED_MODULE_0__["GET_SYNC_COMPLETED"],
data: data
});
handleCallback();
})["catch"](function () {
if (data.hasSyncedWallet) {
var error = 'Error getting synced wallet';

View file

@ -17,6 +17,47 @@ rewards.YOUTUBE_CREATOR = 'youtube_creator';
rewards.TYPE_DAILY_VIEW = 'daily_view';
rewards.claimReward = (type, rewardParams) => {
let reason;
switch (type) {
case rewards.TYPE_NEW_DEVELOPER:
reason = __('for being a new developer!');
break;
case rewards.TYPE_NEW_USER:
reason = __('for being a new user!');
break;
case rewards.TYPE_CONFIRM_EMAIL:
reason = __('for confirming your email!');
break;
case rewards.TYPE_FIRST_CHANNEL:
reason = __('for your first channel!');
break;
case rewards.TYPE_FIRST_STREAM:
reason = __('for your first publish!');
break;
case rewards.TYPE_MANY_DOWNLOADS:
reason = __('for having many downloads!');
break;
case rewards.TYPE_FIRST_PUBLISH:
reason = __('for your first publish!');
break;
case rewards.TYPE_REFERRAL:
reason = __('for a referral!');
break;
case rewards.TYPE_REWARD_CODE:
reason = __('for entering a reward code!');
break;
case rewards.TYPE_SUBSCRIPTION:
reason = __('for adding a subscription!');
break;
case rewards.YOUTUBE_CREATOR:
reason = __('for being a youtube creator!');
break;
case rewards.TYPE_DAILY_VIEW:
reason = __('for viewing content today!');
break;
default:
reason = '.';
}
function requestReward(resolve, reject, params) {
if (!Lbryio.enabled) {
reject(new Error(__('Rewards are not enabled.')));
@ -24,8 +65,10 @@ rewards.claimReward = (type, rewardParams) => {
}
Lbryio.call('reward', 'new', params, 'post').then(reward => {
// different message per type
const message =
reward.reward_notification || `You have claimed a ${reward.reward_amount} LBC reward.`;
reward.reward_notification ||
`You have claimed a ${reward.reward_amount} LBC reward ${reason}`;
// Display global notice
const action = doToast({