fix: head state not updated when using config.yaml as current profile (#5827)

This commit is contained in:
xuvjso 2025-12-14 10:01:46 +08:00 committed by GitHub
parent 34793f9880
commit 37c2428f49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -55,11 +55,6 @@ export function useHeadStateNew() {
const [state, dispatch] = useReducer(headStateReducer, {});
useEffect(() => {
if (!current) {
dispatch({ type: "reset" });
return;
}
try {
const data = JSON.parse(
localStorage.getItem(HEAD_STATE_KEY)!,
@ -78,8 +73,6 @@ export function useHeadStateNew() {
}, [current]);
useEffect(() => {
if (!current) return;
const timer = setTimeout(() => {
try {
const item = localStorage.getItem(HEAD_STATE_KEY);
@ -99,10 +92,9 @@ export function useHeadStateNew() {
const setHeadState = useCallback(
(groupName: string, obj: Partial<HeadState>) => {
if (!current) return;
dispatch({ type: "update", groupName, patch: obj });
},
[current],
[],
);
return [state, setHeadState] as const;