Enable min_tip setting
This commit is contained in:
parent
ff9ca662f2
commit
658e9bd1db
3 changed files with 69 additions and 60 deletions
|
@ -15,7 +15,9 @@ import { getUriForSearchTerm } from 'util/search';
|
||||||
|
|
||||||
const DEBOUNCE_REFRESH_MS = 1000;
|
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 = {
|
type Props = {
|
||||||
activeChannelClaim: ChannelClaim,
|
activeChannelClaim: ChannelClaim,
|
||||||
|
@ -297,47 +299,46 @@ export default function SettingsCreatorPage(props: Props) {
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{FEATURE_IS_READY && (
|
<Card
|
||||||
<Card
|
title={__('Tip')}
|
||||||
title={__('Tip')}
|
actions={
|
||||||
actions={
|
<>
|
||||||
<>
|
<FormField
|
||||||
<FormField
|
name="min_tip_amount_comment"
|
||||||
name="min_tip_amount_comment"
|
label={
|
||||||
label={
|
<I18nMessage tokens={{ lbc: <LbcSymbol /> }}>Minimum %lbc% tip amount for comments</I18nMessage>
|
||||||
<I18nMessage tokens={{ lbc: <LbcSymbol /> }}>Minimum %lbc% tip amount for comments</I18nMessage>
|
}
|
||||||
}
|
helper={__(
|
||||||
helper={__(
|
'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.'
|
)}
|
||||||
)}
|
className="form-field--price-amount"
|
||||||
className="form-field--price-amount"
|
max={LBC_MAX}
|
||||||
min={0}
|
min={LBC_MIN}
|
||||||
step="any"
|
step={LBC_STEP}
|
||||||
type="number"
|
type="number"
|
||||||
placeholder="1"
|
placeholder="3.14"
|
||||||
value={minTipAmountComment}
|
value={minTipAmountComment}
|
||||||
onChange={(e) => setSettings({ min_tip_amount_comment: parseFloat(e.target.value) })}
|
onChange={(e) => setSettings({ min_tip_amount_comment: parseFloat(e.target.value) })}
|
||||||
/>
|
/>
|
||||||
<FormField
|
<FormField
|
||||||
name="min_tip_amount_super_chat"
|
name="min_tip_amount_super_chat"
|
||||||
label={
|
label={
|
||||||
<I18nMessage tokens={{ lbc: <LbcSymbol /> }}>Minimum %lbc% tip amount for hyperchats</I18nMessage>
|
<I18nMessage tokens={{ lbc: <LbcSymbol /> }}>Minimum %lbc% tip amount for hyperchats</I18nMessage>
|
||||||
}
|
}
|
||||||
helper={__(
|
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.'
|
'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"
|
className="form-field--price-amount"
|
||||||
min={0}
|
min={0}
|
||||||
step="any"
|
step="any"
|
||||||
type="number"
|
type="number"
|
||||||
placeholder="1"
|
placeholder="1"
|
||||||
value={minTipAmountSuperChat}
|
value={minTipAmountSuperChat}
|
||||||
onChange={(e) => setSettings({ min_tip_amount_super_chat: parseFloat(e.target.value) })}
|
onChange={(e) => setSettings({ min_tip_amount_super_chat: parseFloat(e.target.value) })}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
<Card
|
<Card
|
||||||
title={__('Delegation')}
|
title={__('Delegation')}
|
||||||
className="card--enable-overflow"
|
className="card--enable-overflow"
|
||||||
|
|
|
@ -1458,21 +1458,21 @@ export const doFetchCreatorSettings = (channelClaimIds: Array<string> = []) => {
|
||||||
*/
|
*/
|
||||||
export const doUpdateCreatorSettings = (channelClaim: ChannelClaim, settings: PerChannelSettings) => {
|
export const doUpdateCreatorSettings = (channelClaim: ChannelClaim, settings: PerChannelSettings) => {
|
||||||
return async (dispatch: Dispatch, getState: GetState) => {
|
return async (dispatch: Dispatch, getState: GetState) => {
|
||||||
let channelSignature: ?{
|
const channelSignature = await channelSignName(channelClaim.claim_id, channelClaim.name);
|
||||||
signature: string,
|
|
||||||
signing_ts: string,
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
channelSignature = await Lbry.channel_sign({
|
|
||||||
channel_id: channelClaim.claim_id,
|
|
||||||
hexdata: toHex(channelClaim.name),
|
|
||||||
});
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
if (!channelSignature) {
|
if (!channelSignature) {
|
||||||
|
devToast(dispatch, 'doUpdateCreatorSettings: failed to sign channel name');
|
||||||
return;
|
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({
|
return Comments.setting_update({
|
||||||
channel_name: channelClaim.name,
|
channel_name: channelClaim.name,
|
||||||
channel_id: channelClaim.claim_id,
|
channel_id: channelClaim.claim_id,
|
||||||
|
@ -1480,12 +1480,7 @@ export const doUpdateCreatorSettings = (channelClaim: ChannelClaim, settings: Pe
|
||||||
signing_ts: channelSignature.signing_ts,
|
signing_ts: channelSignature.signing_ts,
|
||||||
...settings,
|
...settings,
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
dispatch(
|
dispatch(doToast({ message: err.message, isError: true }));
|
||||||
doToast({
|
|
||||||
message: err.message,
|
|
||||||
isError: true,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1023,9 +1023,22 @@ export default handleActions(
|
||||||
// because the GUI only shows 1 channel's setting at a time, and *always*
|
// 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
|
// re-fetches to get latest data before displaying. Either rename this to
|
||||||
// 'activeChannelCreatorSettings', or append the new data properly.
|
// '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 {
|
return {
|
||||||
...state,
|
...state,
|
||||||
settingsByChannelId: action.data,
|
settingsByChannelId,
|
||||||
fetchingSettings: false,
|
fetchingSettings: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue