Skip to content

Commit

Permalink
core: Refactor useFavorites to handle null values in app key
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggling committed Oct 16, 2024
1 parent 8dbe5a5 commit 865dcce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const useFavorites = () => {
const favorite$ = useMemo(
() =>
combineLatest([app?.getAppManifests(), menuFavoritesController.favorites$]).pipe(
map(([apps, favorites]) => apps.filter((app) => favorites.includes(app.key!)))
map(([apps, favorites]) => apps.filter((app) => favorites.includes(app.key ?? '')))
),
[apps]
) as Observable<AppManifest[]>;
Expand Down Expand Up @@ -51,12 +51,13 @@ export const useFavorites = () => {
);

const favoritesWithDisabled =
useMemo(() => favorites.map((p) => ({ ...p, isDisabled: isDisabled(p.key!) })), [favorites, isDisabled]) || [];
useMemo(() => favorites.map((p) => ({ ...p, isDisabled: isDisabled(p.key ?? '') })), [favorites, isDisabled]) ||
[];

const appGroupsWithPinned = useMemo(() => {
return (appCategories || []).map((group) => ({
...group,
apps: group.apps.map((app) => ({ ...app, isPinned: isPinned(app.key!) })),
apps: group.apps.map((app) => ({ ...app, isPinned: isPinned(app.key ?? '') })),
})) as AppCategory[];
}, [isPinned, appCategories]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function getPinnedAppsGroup(enabledApps: AppManifest[], disabledApps: App
} as AppCategory
);

pinnedApps.apps.sort((a, b) => a.name!.localeCompare(b.name!));
pinnedApps.apps.sort((a, b) => (a.name ?? '').localeCompare(b.name ?? ''));

return pinnedApps;
}

0 comments on commit 865dcce

Please sign in to comment.