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 FEATURE_IS_READY = false;
|
||||
const LBC_MAX = 21000000;
|
||||
const LBC_MIN = 0;
|
||||
const LBC_STEP = 1.0;
|
||||
|
||||
type Props = {
|
||||
activeChannelClaim: ChannelClaim,
|
||||
|
@ -297,7 +299,6 @@ export default function SettingsCreatorPage(props: Props) {
|
|||
</div>
|
||||
}
|
||||
/>
|
||||
{FEATURE_IS_READY && (
|
||||
<Card
|
||||
title={__('Tip')}
|
||||
actions={
|
||||
|
@ -311,10 +312,11 @@ export default function SettingsCreatorPage(props: Props) {
|
|||
'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"
|
||||
max={LBC_MAX}
|
||||
min={LBC_MIN}
|
||||
step={LBC_STEP}
|
||||
type="number"
|
||||
placeholder="1"
|
||||
placeholder="3.14"
|
||||
value={minTipAmountComment}
|
||||
onChange={(e) => setSettings({ min_tip_amount_comment: parseFloat(e.target.value) })}
|
||||
/>
|
||||
|
@ -337,7 +339,6 @@ export default function SettingsCreatorPage(props: Props) {
|
|||
</>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<Card
|
||||
title={__('Delegation')}
|
||||
className="card--enable-overflow"
|
||||
|
|
|
@ -1458,21 +1458,21 @@ export const doFetchCreatorSettings = (channelClaimIds: Array<string> = []) => {
|
|||
*/
|
||||
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 }));
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue