diff --git a/ui/page/settingsCreator/view.jsx b/ui/page/settingsCreator/view.jsx index c1c65269b..d7b1af2c0 100644 --- a/ui/page/settingsCreator/view.jsx +++ b/ui/page/settingsCreator/view.jsx @@ -15,7 +15,9 @@ import { getUriForSearchTerm } from 'util/search'; const DEBOUNCE_REFRESH_MS = 1000; -const FEATURE_IS_READY = false; +const LBC_MAX = 21000000; +const LBC_MIN = 0; +const LBC_STEP = 1.0; type Props = { activeChannelClaim: ChannelClaim, @@ -297,47 +299,46 @@ export default function SettingsCreatorPage(props: Props) { } /> - {FEATURE_IS_READY && ( - - }}>Minimum %lbc% tip amount for comments - } - helper={__( - 'Enabling a minimum amount to comment will force all comments, including livestreams, to have tips associated with them. This can help prevent spam.' - )} - className="form-field--price-amount" - min={0} - step="any" - type="number" - placeholder="1" - value={minTipAmountComment} - onChange={(e) => setSettings({ min_tip_amount_comment: parseFloat(e.target.value) })} - /> - }}>Minimum %lbc% tip amount for hyperchats - } - helper={__( - '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.' - )} - className="form-field--price-amount" - min={0} - step="any" - type="number" - placeholder="1" - value={minTipAmountSuperChat} - onChange={(e) => setSettings({ min_tip_amount_super_chat: parseFloat(e.target.value) })} - /> - - } - /> - )} + + }}>Minimum %lbc% tip amount for comments + } + helper={__( + 'Enabling a minimum amount to comment will force all comments, including livestreams, to have tips associated with them. This can help prevent spam.' + )} + className="form-field--price-amount" + max={LBC_MAX} + min={LBC_MIN} + step={LBC_STEP} + type="number" + placeholder="3.14" + value={minTipAmountComment} + onChange={(e) => setSettings({ min_tip_amount_comment: parseFloat(e.target.value) })} + /> + }}>Minimum %lbc% tip amount for hyperchats + } + helper={__( + '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.' + )} + className="form-field--price-amount" + min={0} + step="any" + type="number" + placeholder="1" + value={minTipAmountSuperChat} + onChange={(e) => setSettings({ min_tip_amount_super_chat: parseFloat(e.target.value) })} + /> + + } + /> = []) => { */ export const doUpdateCreatorSettings = (channelClaim: ChannelClaim, settings: PerChannelSettings) => { return async (dispatch: Dispatch, getState: GetState) => { - let channelSignature: ?{ - signature: string, - signing_ts: string, - }; - try { - channelSignature = await Lbry.channel_sign({ - channel_id: channelClaim.claim_id, - hexdata: toHex(channelClaim.name), - }); - } catch (e) {} - + const channelSignature = await channelSignName(channelClaim.claim_id, channelClaim.name); if (!channelSignature) { + devToast(dispatch, 'doUpdateCreatorSettings: failed to sign channel name'); return; } + const BTC_SATOSHIS = 100000000; + + if (settings.min_tip_amount_comment !== undefined) { + settings.min_tip_amount_comment *= BTC_SATOSHIS; + } + if (settings.min_tip_amount_super_chat !== undefined) { + settings.min_tip_amount_super_chat *= BTC_SATOSHIS; + } + return Comments.setting_update({ channel_name: channelClaim.name, channel_id: channelClaim.claim_id, @@ -1480,12 +1480,7 @@ export const doUpdateCreatorSettings = (channelClaim: ChannelClaim, settings: Pe signing_ts: channelSignature.signing_ts, ...settings, }).catch((err) => { - dispatch( - doToast({ - message: err.message, - isError: true, - }) - ); + dispatch(doToast({ message: err.message, isError: true })); }); }; }; diff --git a/ui/redux/reducers/comments.js b/ui/redux/reducers/comments.js index 4b5af666a..6e3ed5f07 100644 --- a/ui/redux/reducers/comments.js +++ b/ui/redux/reducers/comments.js @@ -1023,9 +1023,22 @@ export default handleActions( // because the GUI only shows 1 channel's setting at a time, and *always* // re-fetches to get latest data before displaying. Either rename this to // 'activeChannelCreatorSettings', or append the new data properly. + const settingsByChannelId = Object.assign({}, action.data); + const BTC_SATOSHIS = 100000000; + + const channelIds = Object.keys(settingsByChannelId); + channelIds.forEach((ci) => { + if (settingsByChannelId[ci].min_tip_amount_comment) { + settingsByChannelId[ci].min_tip_amount_comment /= BTC_SATOSHIS; + } + if (settingsByChannelId[ci].min_tip_amount_super_chat) { + settingsByChannelId[ci].min_tip_amount_super_chat /= BTC_SATOSHIS; + } + }); + return { ...state, - settingsByChannelId: action.data, + settingsByChannelId, fetchingSettings: false, }; },