Skip to content

Commit 488c5a4

Browse files
keikarimiko
andauthored
Allow clearing old LBC comment limits from Odysee (#3408)
* Allow clearing old LBC comment limits from Odysee * Minor adjustment * Coderabbit * Bit more adjustment --------- Co-authored-by: miko <sauce47@posteo.net>
1 parent 11a5245 commit 488c5a4

File tree

1 file changed

+27
-6
lines changed
  • ui/page/claim/internal/claimPageComponent/internal/channelPage/tabs/creatorSettingsTab

1 file changed

+27
-6
lines changed

ui/page/claim/internal/claimPageComponent/internal/channelPage/tabs/creatorSettingsTab/view.jsx

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export default function CreatorSettingsTab(props: Props) {
8282
const focusedField = React.useRef('');
8383

8484
const pushSlowModeMinDebounced = React.useMemo(() => debounce(pushSlowModeMin, 1000), []); // eslint-disable-line react-hooks/exhaustive-deps
85+
const pushMinTipDebounced = React.useMemo(() => debounce(pushMinTip, 1000), []); // eslint-disable-line react-hooks/exhaustive-deps
8586
const pushMinSuperDebounced = React.useMemo(() => debounce(pushMinSuper, 1000), []); // eslint-disable-line react-hooks/exhaustive-deps
8687
const pushMinUSDTipDebounced = React.useMemo(() => debounce(pushMinUSDTip, 1000), []); // eslint-disable-line react-hooks/exhaustive-deps
8788
const pushMinUSDSuperDebounced = React.useMemo(() => debounce(pushMinUSDSuper, 1000), []); // eslint-disable-line react-hooks/exhaustive-deps
@@ -110,6 +111,8 @@ export default function CreatorSettingsTab(props: Props) {
110111

111112
if (fullSync) {
112113
setCommentsEnabled(settings.comments_enabled || false);
114+
focusedField.current !== FIELD_NAMES.MIN_TIP && setMinTip(settings.min_tip_amount_comment || 0);
115+
focusedField.current !== FIELD_NAMES.MIN_SUPER && setMinSuper(settings.min_tip_amount_super_chat || 0);
113116
focusedField.current !== FIELD_NAMES.MIN_USD_TIP && setMinUSDTip(settings.min_usdc_tip_amount_comment || 0);
114117
focusedField.current !== FIELD_NAMES.MIN_USD_SUPER &&
115118
setMinUSDSuper(settings.min_usdc_tip_amount_super_chat || 0);
@@ -162,6 +165,10 @@ export default function CreatorSettingsTab(props: Props) {
162165
updateCreatorSettings(activeChannelClaim, { slow_mode_min_gap: value });
163166
}
164167

168+
function pushMinTip(value: number, activeChannelClaim: ChannelClaim) {
169+
updateCreatorSettings(activeChannelClaim, { min_tip_amount_comment: value });
170+
}
171+
165172
function pushMinUSDTip(value: number, activeChannelClaim: ChannelClaim) {
166173
updateCreatorSettings(activeChannelClaim, { min_usdc_tip_amount_comment: value });
167174
}
@@ -394,21 +401,26 @@ export default function CreatorSettingsTab(props: Props) {
394401
className="form-field--price-amount"
395402
type="number"
396403
placeholder="0"
397-
value={minUSDTip}
404+
value={minUSDTip || (minTip ? 0.01 : minUSDTip)} // Default to 0.01 if LBC limit is used, so user has way to clear it on Odysee
398405
onChange={(e) => {
399406
const newMinUSDTip = parseFloat(e.target.value);
400407
setMinUSDTip(newMinUSDTip);
401408
pushMinUSDTipDebounced(newMinUSDTip || 0, activeChannelClaim);
402409
if (newMinUSDTip !== 0) {
403-
if (minSuper !== 0) {
404-
setMinSuper(0);
405-
pushMinSuperDebounced(0, activeChannelClaim);
406-
}
407410
if (minUSDSuper !== 0) {
408411
setMinUSDSuper(0);
409412
pushMinUSDSuperDebounced(0, activeChannelClaim);
410413
}
411414
}
415+
// Clear old LBC values if changing the value
416+
if (minTip !== 0) {
417+
setMinTip(0);
418+
pushMinTipDebounced(0, activeChannelClaim);
419+
}
420+
if (minSuper !== 0) {
421+
setMinSuper(0);
422+
pushMinSuperDebounced(0, activeChannelClaim);
423+
}
412424
}}
413425
onFocus={() => (focusedField.current = FIELD_NAMES.MIN_USD_TIP)}
414426
onBlur={() => setLastUpdated(Date.now())}
@@ -435,12 +447,21 @@ export default function CreatorSettingsTab(props: Props) {
435447
step="any"
436448
type="number"
437449
placeholder="0"
438-
value={minUSDSuper}
450+
value={minUSDSuper || (minSuper ? 0.01 : minUSDSuper)} // Default to 0.01 if LBC limit is used, so user has way to clear it on Odysee
439451
disabled={!!minTip || !!minUSDTip}
440452
onChange={(e) => {
441453
const newMinUSDSuper = parseFloat(e.target.value);
442454
setMinUSDSuper(newMinUSDSuper);
443455
pushMinUSDSuperDebounced(newMinUSDSuper || 0, activeChannelClaim);
456+
// Clear old LBC values if changing the value
457+
if (minTip !== 0) {
458+
setMinTip(0);
459+
pushMinTipDebounced(0, activeChannelClaim);
460+
}
461+
if (minSuper !== 0) {
462+
setMinSuper(0);
463+
pushMinSuperDebounced(0, activeChannelClaim);
464+
}
444465
}}
445466
onFocus={() => (focusedField.current = FIELD_NAMES.MIN_USD_SUPER)}
446467
onBlur={() => setLastUpdated(Date.now())}

0 commit comments

Comments
 (0)