utils.ts
1 import type { ComponentType } from 'svelte'; 2 import type { 3 BaseNavigationItem, 4 NavigationId, 5 } from '@amp/web-app-components/src/types'; 6 import Item from './Item.svelte'; 7 8 export function isSameTab( 9 a: NavigationId | null, 10 b: NavigationId | null, 11 ): boolean { 12 if (a === null || b === null) { 13 return false; 14 } 15 16 // Need deep object equality for things like 17 // { kind: 'playlist', id: '123' } 18 try { 19 return JSON.stringify(a) === JSON.stringify(b); 20 } catch { 21 return false; 22 } 23 } 24 25 export function getItemComponent(item: BaseNavigationItem): ComponentType { 26 return item.component ?? Item; 27 }