forked from Blendman974/faceclaw
Optimize phone CPU usage
This commit is contained in:
1 parent
449cb0bf73
commit
45d2ece0d2
19 files changed
+485
-103
No files matched your search
@@ -51,9 +51,19 @@ export function installedEvenHubPackageId(appId: string): string | null {
|
||||
}
|
||||
}
|
||||
|
||||
// The parsed index for the last stored value: the launcher and the watch
|
||||
// state both list installed apps on every refresh, and the sort's
|
||||
// localeCompare dominated the cost.
|
||||
let parsedIndex: { raw: string; apps: InstalledEvenHubApp[] } | null = null;
|
||||
|
||||
export function getInstalledEvenHubApps(): InstalledEvenHubApp[] {
|
||||
const raw = getStringSetting(STORAGE_KEY, "");
|
||||
if (!raw) return [];
|
||||
if (parsedIndex?.raw !== raw) parsedIndex = { raw, apps: parseInstalledIndex(raw) };
|
||||
return parsedIndex.apps.map((app) => ({ ...app }));
|
||||
}
|
||||
|
||||
function parseInstalledIndex(raw: string): InstalledEvenHubApp[] {
|
||||
try {
|
||||
const parsed = JSON.parse(raw);
|
||||
if (!Array.isArray(parsed)) return [];
|
||||
|
||||
Reference in new issue
Block a user