Commit 19278f18 by luoqi

fix(web): 修左栏默认 tab 回落竞态(首帧误切 pool 致 tab/数据错位)

上个改动的 auto-fallback 未卡「加载完成」转变:usePatientPicker 的 loading 初值 false、
total 初值 0,首帧即满足 !loading&&total===0 → 抢在「我的」加载前切 pool,而并发守卫又跳过
pool 的 fetch → tab=召回池 但数据仍是「我的」。改为等 loading true→false 完成一次再判空。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
parent 0de83ea9
Pipeline #3376 failed in 0 seconds
...@@ -101,9 +101,15 @@ export function PatientPickerRail({ ...@@ -101,9 +101,15 @@ export function PatientPickerRail({
// 默认「我的」加载完成后若为空 → 自动回落「召回池」(只一次)。 // 默认「我的」加载完成后若为空 → 自动回落「召回池」(只一次)。
// 与落地页 mine 优先、空则 pool 的默认患者策略一致,避免左栏 tab 与所选患者来源不符。 // 与落地页 mine 优先、空则 pool 的默认患者策略一致,避免左栏 tab 与所选患者来源不符。
// ⚠️ 必须等「一次真实加载完成」(loading true→false)再判空:usePatientPicker 的 loading
// 初值是 false、total 初值 0,若不卡这个转变,首帧就会误判空而抢切 pool(且并发守卫会
// 跳过 pool 的 fetch → 出现 tab=召回池 但数据仍是我的 的错位)。
const prevLoadingRef = useRef(false);
useEffect(() => { useEffect(() => {
const justFinished = prevLoadingRef.current && !loading; // 刚从加载中变为完成
prevLoadingRef.current = loading;
if (autoFellBackRef.current) return; if (autoFellBackRef.current) return;
if (view === 'mine' && !loading && total === 0) { if (view === 'mine' && justFinished && total === 0) {
autoFellBackRef.current = true; autoFellBackRef.current = true;
setView('pool'); setView('pool');
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment