Skip to content

fix(web/system-settings): refresh status cache on RegistrationCodeEnabled change - #7

Merged
ItzArona merged 1 commit into
mainfrom
dev
Jul 25, 2026
Merged

fix(web/system-settings): refresh status cache on RegistrationCodeEnabled change#7
ItzArona merged 1 commit into
mainfrom
dev

Conversation

@ItzPlana

@ItzPlana ItzPlana commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

开启「邀请码注册」(RegistrationCodeEnabled)后,侧边栏的 Registration Codes 管理入口不会立即出现,必须硬刷新页面才能看到。

原因:系统设置保存 hook(web/src/features/system-settings/hooks/use-update-option.ts)中的 STATUS_RELATED_KEYS 白名单决定哪些配置项保存后需要失效 ['status'] 查询缓存并清除 localStorage 中的 status 副本。RegistrationCodeEnabled 不在白名单内,保存后前端 status 缓存(React Query staleTime 5 分钟 + localStorage placeholderData)保留旧值,而侧边栏入口由 status.registration_code_enabled 门控(use-sidebar-data.ts),因此不刷新就不更新。

修复:将 RegistrationCodeEnabled 加入 STATUS_RELATED_KEYS(与 HeaderNavModulesSidebarModulesAdmin 等同类前端显示相关 key 一致)。保存开关后立即重新拉取 /api/status 并更新 localStorage,侧边栏入口随保存即时出现/消失,无需刷新页面。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

  • 无(fork 内部修复,问题由本仓库新增的邀请码注册功能 0954cdd 引入)

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

改动为向既有字符串常量数组新增一项(+1 行),缓存失效行为由该白名单的既有机制保证(同列表其他 key 已验证的路径)。本地尚未运行前端构建验证;验证方式:构建后在系统设置中切换「邀请码注册」开关,侧边栏 Registration Codes 入口应随保存即时出现/消失,无需刷新。

🤖 Generated with Claude Code

…bled change

Add RegistrationCodeEnabled to STATUS_RELATED_KEYS so saving the switch
invalidates the ['status'] query and clears the localStorage copy. The
sidebar Registration Codes entry is gated on
status.registration_code_enabled and previously only appeared after a
hard refresh.
@ItzArona
ItzArona requested a review from Copilot July 25, 2026 09:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ItzArona ItzArona self-assigned this Jul 25, 2026
@ItzArona
ItzArona merged commit 6586c44 into main Jul 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants