fix: 修复同步问题
This commit is contained in:
@@ -207,6 +207,7 @@ export default function MarketIndexAccordion({
|
|||||||
const [settingOpen, setSettingOpen] = useState(false);
|
const [settingOpen, setSettingOpen] = useState(false);
|
||||||
const [tickerIndex, setTickerIndex] = useState(0);
|
const [tickerIndex, setTickerIndex] = useState(0);
|
||||||
const rootRef = useRef(null);
|
const rootRef = useRef(null);
|
||||||
|
const hasInitializedSelectedCodes = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const el = rootRef.current;
|
const el = rootRef.current;
|
||||||
@@ -257,6 +258,7 @@ export default function MarketIndexAccordion({
|
|||||||
// 初始化选中指数(本地偏好 > 默认集合)
|
// 初始化选中指数(本地偏好 > 默认集合)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!indices.length || typeof window === 'undefined') return;
|
if (!indices.length || typeof window === 'undefined') return;
|
||||||
|
if (hasInitializedSelectedCodes.current) return;
|
||||||
try {
|
try {
|
||||||
const stored = window.localStorage.getItem('marketIndexSelected');
|
const stored = window.localStorage.getItem('marketIndexSelected');
|
||||||
const availableCodes = new Set(indices.map((it) => it.code));
|
const availableCodes = new Set(indices.map((it) => it.code));
|
||||||
@@ -266,6 +268,7 @@ export default function MarketIndexAccordion({
|
|||||||
const filtered = parsed.filter((c) => availableCodes.has(c));
|
const filtered = parsed.filter((c) => availableCodes.has(c));
|
||||||
if (filtered.length) {
|
if (filtered.length) {
|
||||||
setSelectedCodes(filtered);
|
setSelectedCodes(filtered);
|
||||||
|
hasInitializedSelectedCodes.current = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1624,7 +1624,9 @@ export default function HomePage() {
|
|||||||
if (key === 'funds') {
|
if (key === 'funds') {
|
||||||
const prevSig = getFundCodesSignature(prevValue);
|
const prevSig = getFundCodesSignature(prevValue);
|
||||||
const nextSig = getFundCodesSignature(nextValue);
|
const nextSig = getFundCodesSignature(nextValue);
|
||||||
if (prevSig === nextSig) return;
|
if (prevSig === nextSig) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!skipSyncRef.current) {
|
if (!skipSyncRef.current) {
|
||||||
const now = nowInTz().toISOString();
|
const now = nowInTz().toISOString();
|
||||||
|
|||||||
Reference in New Issue
Block a user