Desktop: folders keep claiming their store records before the config read returns; a store app with a folder's id is never listed twice

This commit is contained in:
CRTkafa 2026-10-23 09:18:03 +08:00
parent 5e82010ace
commit 7c769c18f4
3 changed files with 38 additions and 2 deletions

View file

@ -224,11 +224,18 @@ export function DataProvider({ children }: { children: ReactNode }) {
setStoreApps(Object.fromEntries((Array.isArray(s) ? s : []).filter(x => x && typeof x.account === 'string').map(x => [x.account, x.entry ?? null])));
}, []);
// the last config summary seen per folder: a folder whose read has not come back yet (start) or failed this time keeps
// claiming its store records, so its App Store / Play entries never show up a second time as store-only apps
const lastSummary = useRef(new Map<string, NonNullable<PortfolioResult['apps'][number]['summary']>>());
const apps = useMemo(() => buildApps({
projects, accounts, overrides,
summaryOf: p => portfolio?.apps.find(a => a.project === p.path)?.summary ?? liveRef.current?.value.apps.find(a => a.project === p.path)?.summary,
summaryOf: p => {
const fresh = portfolio?.apps.find(a => a.project === p.path)?.summary ?? live?.value.apps.find(a => a.project === p.path)?.summary;
if (fresh) lastSummary.current.set(p.path, fresh);
return fresh ?? lastSummary.current.get(p.path);
},
storeApps: Object.entries(storeApps).filter(([, e]) => !!e).map(([account, e]) => ({ account, apps: e!.value.apps })),
}), [projects, accounts, overrides, portfolio, storeApps]);
}), [projects, accounts, overrides, portfolio, live, storeApps]);
const appsRef = useRef(apps);
appsRef.current = apps;