[PR #6144] [CLOSED] fix(frontend): preserve edited server drafts #6107

Closed
opened 2026-11-02 04:06:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6144
Author: @PathGao
Created: 7/29/2026
Status: ❌ Closed

Base: main ← Head: fix-server-draft-hydration


📝 Commits (3)

  • 9373763 fix(frontend): preserve edited server drafts
  • b888a1b fix(frontend): retain Xray server projections
  • f6cd87a fix(frontend): keep draft controls internal

📊 Changes

6 files changed (+248 additions, -39 deletions)

View changed files

📝 frontend/src/api/queries/useAllSettings.ts (+13 -13)
➕ frontend/src/hooks/useServerDraft.ts (+42 -0)
📝 frontend/src/hooks/useXraySetting.ts (+25 -26)
📝 frontend/src/test/use-all-settings.test.tsx (+21 -0)
➕ frontend/src/test/use-xray-setting.test.tsx (+71 -0)
➕ frontend/src/test/useServerDraft.test.tsx (+76 -0)

📄 Description

Problem

A successful settings/Xray save invalidates the query. If the user continues editing before that refetch returns, the old hydration path can overwrite the newer unsaved input. Xray also polls every second only to derive whether Save is enabled.

Change

  • Add a small server-draft hook shared by Settings hydration.
  • Hydrate only on first load, when the draft is clean, after explicit discard, or when the refetch confirms the just-saved draft.
  • Preserve a later edit while an earlier save refetches.
  • Replace Xray's dirty-state polling with render-time comparison.

Regression coverage

  • Keep edited data through a refetch.
  • Clear dirty state when the refetch confirms the saved draft.
  • Hydrate clean drafts and explicit discards.

Validation

  • make verify

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6144 **Author:** [@PathGao](https://github.com/PathGao) **Created:** 7/29/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-server-draft-hydration` --- ### 📝 Commits (3) - [`9373763`](https://github.com/MHSanaei/3x-ui/commit/9373763679e49bf5ebf730416d03565c53ca6f99) fix(frontend): preserve edited server drafts - [`b888a1b`](https://github.com/MHSanaei/3x-ui/commit/b888a1b3988a4759f778e05c89d003f97be2c06e) fix(frontend): retain Xray server projections - [`f6cd87a`](https://github.com/MHSanaei/3x-ui/commit/f6cd87acaad77dc65cf205acd3d605148d1bcca8) fix(frontend): keep draft controls internal ### 📊 Changes **6 files changed** (+248 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/api/queries/useAllSettings.ts` (+13 -13) ➕ `frontend/src/hooks/useServerDraft.ts` (+42 -0) 📝 `frontend/src/hooks/useXraySetting.ts` (+25 -26) 📝 `frontend/src/test/use-all-settings.test.tsx` (+21 -0) ➕ `frontend/src/test/use-xray-setting.test.tsx` (+71 -0) ➕ `frontend/src/test/useServerDraft.test.tsx` (+76 -0) </details> ### 📄 Description ## Problem A successful settings/Xray save invalidates the query. If the user continues editing before that refetch returns, the old hydration path can overwrite the newer unsaved input. Xray also polls every second only to derive whether Save is enabled. ## Change - Add a small server-draft hook shared by Settings hydration. - Hydrate only on first load, when the draft is clean, after explicit discard, or when the refetch confirms the just-saved draft. - Preserve a later edit while an earlier save refetches. - Replace Xray's dirty-state polling with render-time comparison. ## Regression coverage - Keep edited data through a refetch. - Clear dirty state when the refetch confirms the saved draft. - Hydrate clean drafts and explicit discards. ## Validation - `make verify` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:25 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6107
No description provided.