refactor album expansion to global scope

This commit is contained in:
jeffvli
2026-02-13 14:59:15 -08:00
parent e855f7dd01
commit 70fdd4bdc3
14 changed files with 297 additions and 225 deletions
@@ -2,27 +2,18 @@ import { Suspense } from 'react';
import styles from './expanded-list-item.module.css';
import {
ItemListStateActions,
ItemListStateItem,
useItemListStateSubscription,
} from '/@/renderer/components/item-list/helpers/item-list-state';
import { ItemListStateItem } from '/@/renderer/components/item-list/helpers/item-list-state';
import { ExpandedAlbumListItem } from '/@/renderer/features/albums/components/expanded-album-list-item';
import { Spinner } from '/@/shared/components/spinner/spinner';
import { LibraryItem } from '/@/shared/types/domain-types';
interface ExpandedListItemProps {
internalState: ItemListStateActions;
item?: ItemListStateItem;
itemType: LibraryItem;
}
export const ExpandedListItem = ({ internalState, itemType }: ExpandedListItemProps) => {
const expandedItems = useItemListStateSubscription(internalState, () =>
internalState ? internalState.getExpandedItemsCached() : [],
);
const currentItem = expandedItems[0];
if (!currentItem) {
export const ExpandedListItem = ({ item, itemType }: ExpandedListItemProps) => {
if (!item) {
return null;
}
@@ -30,11 +21,7 @@ export const ExpandedListItem = ({ internalState, itemType }: ExpandedListItemPr
<div className={styles.container}>
<div className={styles.inner}>
<Suspense fallback={<Spinner container />}>
<SelectedItem
internalState={internalState}
item={currentItem as ItemListStateItem}
itemType={itemType}
/>
<SelectedItem item={item} itemType={itemType} />
</Suspense>
</div>
</div>
@@ -42,15 +29,14 @@ export const ExpandedListItem = ({ internalState, itemType }: ExpandedListItemPr
};
interface SelectedItemProps {
internalState: ItemListStateActions;
item: ItemListStateItem;
itemType: LibraryItem;
}
const SelectedItem = ({ internalState, item, itemType }: SelectedItemProps) => {
const SelectedItem = ({ item, itemType }: SelectedItemProps) => {
switch (itemType) {
case LibraryItem.ALBUM:
return <ExpandedAlbumListItem internalState={internalState} item={item} />;
return <ExpandedAlbumListItem item={item} />;
default:
return null;
}