fix(sync): isolate installed sync state

This commit is contained in:
2026-05-19 02:03:29 +08:00
parent 753f91e837
commit 34551fce7b
6 changed files with 269 additions and 12 deletions
+19
View File
@@ -28,3 +28,22 @@ export const buildSyncItems = (apps: App[]): SyncedAppListItem[] => {
export const cloudItemKey = (
item: Pick<SyncedAppListItem, "origin" | "pkgname">,
): string => `${item.origin}:${item.pkgname}`;
export const mergeInstalledApps = (
currentApps: App[],
refreshedApps: App[],
refreshedOrigins: Array<"spark" | "apm">,
): App[] => {
const refreshedKeys = new Set(
refreshedApps.map((app) => `${app.origin}:${app.pkgname}`),
);
return [
...currentApps.filter(
(app) =>
!refreshedOrigins.includes(app.origin) &&
!refreshedKeys.has(`${app.origin}:${app.pkgname}`),
),
...refreshedApps,
];
};