Skip to content

Commit

Permalink
Creator Settings now require a minimum staked LBC.
Browse files Browse the repository at this point in the history
  • Loading branch information
infinite-persistence authored and tzarebczan committed May 26, 2021
1 parent 112947a commit 06c6018
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
2 changes: 2 additions & 0 deletions static/app-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1873,6 +1873,8 @@
"Enabling a minimum amount to comment will force all comments, including livestreams, to have tips associated with them. This can help prevent spam.": "Enabling a minimum amount to comment will force all comments, including livestreams, to have tips associated with them. This can help prevent spam.",
"Minimum %lbc% tip amount for hyperchats": "Minimum %lbc% tip amount for hyperchats",
"Enabling a minimum amount to hyperchat will force all TIPPED comments to have this value in order to be shown. This still allows regular comments to be posted.": "Enabling a minimum amount to hyperchat will force all TIPPED comments to have this value in order to be shown. This still allows regular comments to be posted.",
"Settings unavailable for this channel": "Settings unavailable for this channel",
"This channel isn't staking enough LBRY Credits to enable Creator Settings.": "This channel isn't staking enough LBRY Credits to enable Creator Settings.",
"We apologize for this inconvenience, but have added this additional step to prevent abuse. Users on VPN or shared connections will continue to see this message and are not eligible for Rewards.": "We apologize for this inconvenience, but have added this additional step to prevent abuse. Users on VPN or shared connections will continue to see this message and are not eligible for Rewards.",
"Help LBRY Save Crypto": "Help LBRY Save Crypto",
"The US government is attempting to destroy the cryptocurrency industry. Can you help?": "The US government is attempting to destroy the cryptocurrency industry. Can you help?",
Expand Down
13 changes: 11 additions & 2 deletions ui/page/settingsCreator/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ export default function SettingsCreatorPage(props: Props) {
}
}, [lastUpdated, activeChannelClaim, fetchCreatorSettings]);

const isBusy = !activeChannelClaim || !settingsByChannelId || !settingsByChannelId[activeChannelClaim.claim_id];
const isBusy =
!activeChannelClaim || !settingsByChannelId || settingsByChannelId[activeChannelClaim.claim_id] === undefined;
const isDisabled =
activeChannelClaim && settingsByChannelId && settingsByChannelId[activeChannelClaim.claim_id] === null;

return (
<Page
Expand All @@ -138,7 +141,13 @@ export default function SettingsCreatorPage(props: Props) {
<Spinner />
</div>
)}
{!isBusy && (
{isDisabled && (
<Card
title={__('Settings unavailable for this channel')}
subtitle={__("This channel isn't staking enough LBRY Credits to enable Creator Settings.")}
/>
)}
{!isBusy && !isDisabled && (
<>
{FEATURE_IS_READY && (
<Card
Expand Down
26 changes: 25 additions & 1 deletion ui/redux/actions/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,31 @@ export const doFetchCreatorSettings = (channelClaimIds: Array<string> = []) => {
data: settingsByChannelId,
});
})
.catch(() => {
.catch((err) => {
// TODO: Use error codes when available.
// TODO: The "validation is disallowed" thing ideally should just be a
// success case that returns a null setting, instead of an error.
// As we are using 'Promise.all', if one channel fails, everyone
// fails. This forces us to remove the batch functionality of this
// function. However, since this "validation is disallowed" thing
// is potentially a temporary one to handle spammers, I retained
// the batch functionality for now.
if (err.message === 'validation is disallowed for non controlling channels') {
const settingsByChannelId = {};
for (let i = 0; i < channelSignatures.length; ++i) {
const channelId = channelSignatures[i].claim_id;
// 'undefined' means "fetching or have not fetched";
// 'null' means "feature not available for this channel";
settingsByChannelId[channelId] = null;
}

dispatch({
type: ACTIONS.COMMENT_FETCH_SETTINGS_COMPLETED,
data: settingsByChannelId,
});
return;
}

dispatch({
type: ACTIONS.COMMENT_FETCH_SETTINGS_FAILED,
});
Expand Down

0 comments on commit 06c6018

Please sign in to comment.