fix(panel): guild settings not pre-filling from database
Some checks failed
Deploy to Production / test (push) Failing after 33s

Guild draft was initialized with defaults before the API response
arrived, then never updated because the !guildDraft guard prevented
overwriting. Gate initialization on !loading so saved values are used.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
syntaxbullet
2026-04-05 15:28:40 +02:00
parent 56db5bc998
commit 94d259e92a

View File

@@ -20,7 +20,6 @@ import {
useSettings,
type GameSettings,
type GuildSettings,
type SettingsMeta,
} from "../lib/useSettings";
import {
GuildSection,
@@ -107,14 +106,14 @@ export default function Settings() {
}, [settings, gameDraft]);
useEffect(() => {
if (!guildDraft) {
if (!guildDraft && !loading) {
setGuildDraft(
guildSettings
? structuredClone(guildSettings)
: { ...defaultGuildSettings, guildId: meta?.guildId ?? "" }
);
}
}, [guildSettings, guildDraft, meta?.guildId]);
}, [guildSettings, guildDraft, meta?.guildId, loading]);
const isGuildTab = activeSection === "guild";