Skip to content

Commit 16fcc4c

Browse files
committed
social: a failed Auto-send settings read is drawn as an error row (#3367)
`FriendChatSettings` read `social/settings` with an empty rejection branch, so a failed read left the Auto-send checkbox at its initial `false` and the switch live: the card drew "my Bots' replies to this friend go out without asking" as the state the person chose. The value is now `null` until a read answers, a failure draws one quiet `friend-auto-read-error` status row through the existing `errorText()`, and the checkbox is not offered while the value is unknown. A read that answers draws on and off exactly as before, a remount retries, and there is no new copy or button. Docs-not-needed: the card's copy, its box and its hint are unchanged; the new row shows the existing `errorText()` sentence and the issue scopes the diff to `FriendChatSettings` plus the new test file.
1 parent 338304d commit 16fcc4c

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎changelog.d/3367.fixed.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A friend Bot's settings card no longer draws a failed Auto-send read as the setting being off: until a read answers, one quiet line says the read failed and the switch is not offered, so "my Bots ask first" can no longer read as a state the person chose ([#3367](https://github.com/ThinkFlowLab/FlyBot/issues/3367)).

‎plugins/social/client.js‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3759,14 +3759,25 @@ window.__ModuleLoader__.load({
37593759
const remote = bot?.remote
37603760
const home = remote?.home
37613761
const handle = remote?.handle
3762-
const [auto, setAuto] = useState(false)
3762+
// #3366: `null` is "nobody read it yet". A read that failed used to leave `false` here, which is
3763+
// drawn exactly like a setting that is off — and the switch stayed live, so the person could read
3764+
// "my Bots ask first" as a state they chose. The failure is the card's answer while it lasts, and
3765+
// the value stays unknown until a read answers (#3323/#3325/#3359 for the same shape elsewhere).
3766+
const [auto, setAuto] = useState(null)
37633767
const [saving, setSaving] = useState(false)
37643768
const [busy, setBusy] = useState(false)
37653769
const [asking, setAsking] = useState(false)
37663770
const [error, setError] = useState('')
3771+
const [readError, setReadError] = useState('')
37673772
useEffect(() => {
37683773
if (!home) return undefined
3769-
call('social/settings', {}).then(value => setAuto(value?.autoAccept?.[home] === true), () => {})
3774+
let live = true
3775+
call('social/settings', {}).then(value => {
3776+
if (!live) return
3777+
setAuto(value?.autoAccept?.[home] === true)
3778+
setReadError('')
3779+
}, e => { if (live) setReadError(errorText(e)) })
3780+
return () => { live = false }
37703781
}, [home])
37713782
if (!handle) return null
37723783
const toggleAuto = async (on) => {
@@ -3813,9 +3824,10 @@ window.__ModuleLoader__.load({
38133824
// The box holds the setting only; the destructive link sits apart, below it (#274).
38143825
h('div', { className: 'fs-card fs-friend-auto', 'data-flybot': 'friend-auto-box' },
38153826
h('label', { className: 'fs-auto', title: tr(AUTO_SEND_NOTE), 'data-flybot': 'friend-auto-send' },
3816-
h('input', { type: 'checkbox', checked: auto === true, disabled: saving || !home, onChange: e => toggleAuto(e.target.checked) }),
3827+
h('input', { type: 'checkbox', checked: auto === true, disabled: saving || !home || auto === null, onChange: e => toggleAuto(e.target.checked) }),
38173828
tr("Auto-send my Bots' replies to {who}", { who })),
3818-
h('div', { className: 'fs-hint', 'data-flybot': 'friend-auto-hint' }, tr("Your Bots' replies to {who} go out without asking you first. What you type is not affected.", { who }))),
3829+
h('div', { className: 'fs-hint', 'data-flybot': 'friend-auto-hint' }, tr("Your Bots' replies to {who} go out without asking you first. What you type is not affected.", { who })),
3830+
readError ? h('div', { className: 'fs-status', 'data-tone': 'error', role: 'status', 'data-flybot': 'friend-auto-read-error' }, readError) : null),
38193831
h('div', { className: 'fs-friend-remove', 'data-flybot': 'friend-remove-row' }, asking
38203832
? h('span', { className: 'fs-leave-ask', 'data-flybot': 'remove-friend-bot-confirm' },
38213833
h('span', { className: 'fs-hint' }, tr('Remove {bot} from your list? {note}', { bot: botWithOwner(bot.name, named), note: keepLine })),

0 commit comments

Comments
 (0)