fix(desktop): register a community field clear as a real change - #6379
Open
shawnhank wants to merge 1 commit into
Open
fix(desktop): register a community field clear as a real change#6379shawnhank wants to merge 1 commit into
shawnhank wants to merge 1 commit into
Conversation
resolveCommunityUpdateResult's hasChange check required updates.<field> !== undefined for token and reposDir, but clearing either optional field to empty always produces exactly undefined. That meant a save whose only change was clearing one of these fields was classified "unchanged" and silently dropped -- the field would appear cleared in the dialog, then revert on next open. Check key presence instead of value for these two fields so an explicit clear-to-undefined registers as a change, same as any other edit. Signed-off-by: Shawn Hank <shawn@shawnhank.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resolveCommunityUpdateResult(desktop/src/features/communities/useCommunities.tsx) gates whether a community edit persists on ahasChangecheck. For the two optional, clearable fields (token,reposDir), that check wasupdates.<field> !== undefined.Clearing either field to empty always produces exactly
undefined(the dialog'sexpandTilde("")/token.trim() || undefinedboth resolve an empty input toundefined, matchingPartial<Community>'s existing "clear this field" convention). So a save whose only change was clearingreposDirortokenwas classifiedunchangedand silently dropped — the field looked cleared in the dialog, then reverted to the old value the next time it was opened, with no error and no indication anything went wrong.Live repro: set a community's Repos Directory to a path, clear the field, Save Changes, reopen — the old value is back.
Fix
Check key presence (
Object.hasOwn(updates, "token" | "reposDir")) instead of value for these two fields, so an explicit clear-to-undefinedregisters as a real change, the same as any other edit.name/relayUrl/pubkeyare unaffected — they're never intentionally cleared through this path.Test plan
resolveCommunityUpdateResult.test.mjs: clearingreposDiralone registers asupdated/requiresReinit: true; clearingtokenalone does the same; omitting the key entirely (genuinely untouched) still correctly resolves tounchanged.node --import ./test-loader.mjs --experimental-strip-types --test src/features/communities/resolveCommunityUpdateResult.test.mjs— 12/12 pass.pnpm test) — 5,102/5,102 pass, no regressions.tsc --noEmitclean.git showthat the bug is present in both thedesktop-v0.5.16anddesktop-v0.5.17tags, not a recent regression.🤖 Generated with Claude Code