Skip to content

Commit

Permalink
fix(phone\common\hooks): correctly handle already loaded apps (#1148)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukealford authored Apr 6, 2024
1 parent c663640 commit 781f4e5
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions apps/phone/src/common/hooks/useExternalApps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,14 @@ const useExternalAppsAction = () => {
}, []);

const getConfigs = useCallback(
async (externalApps: string[], existingApps: any[]) => {
async (externalApps: string[], existingApps: IApp[]) => {
const appAlreadyLoaded = (appName: string) => {
return existingApps.some((app) => app.id === appName);
return existingApps.find((app) => app.id === appName);
};

const configs = await Promise.all(
externalApps.map(async (appName) => {
if (appAlreadyLoaded(appName)) return null;

const app = await generateAppConfig(appName);
if (!app) return null;
return app;
return appAlreadyLoaded(appName) ?? await generateAppConfig(appName);
}),
);

Expand Down

0 comments on commit 781f4e5

Please sign in to comment.