mirror of
https://github.com/jeffvli/feishin.git
synced 2026-07-21 01:46:32 +02:00
refactor album expansion to global scope
This commit is contained in:
@@ -8,6 +8,7 @@ import { ContextMenuController } from '/@/renderer/features/context-menu/context
|
||||
import { usePlayer } from '/@/renderer/features/player/context/player-context';
|
||||
import { useSetFavorite } from '/@/renderer/features/shared/hooks/use-set-favorite';
|
||||
import { useSetRating } from '/@/renderer/features/shared/hooks/use-set-rating';
|
||||
import { useAppStore } from '/@/renderer/store';
|
||||
import { LibraryItem, QueueSong, Song } from '/@/shared/types/domain-types';
|
||||
import { Play, TableColumn } from '/@/shared/types/types';
|
||||
|
||||
@@ -277,19 +278,27 @@ export const useDefaultItemListControls = (args?: UseDefaultItemListControlsArgs
|
||||
}
|
||||
},
|
||||
|
||||
onExpand: ({ internalState, item }: DefaultItemControlProps) => {
|
||||
if (!item || !internalState) {
|
||||
return;
|
||||
}
|
||||
onExpand: ({ item, itemType }: DefaultItemControlProps) => {
|
||||
if (!item) return;
|
||||
|
||||
// Extract rowId from the item
|
||||
const rowId = internalState.extractRowId(item);
|
||||
if (!rowId) return;
|
||||
|
||||
// Use the item directly (rowId is separate, used only as key in state)
|
||||
const itemListItem = item as ItemListStateItemWithRequiredProperties;
|
||||
const setGlobalExpanded = useAppStore.getState().actions.setGlobalExpanded;
|
||||
const globalExpanded = useAppStore.getState().globalExpanded;
|
||||
|
||||
return internalState?.toggleExpanded(itemListItem);
|
||||
if (globalExpanded?.item?.id === item.id) {
|
||||
setGlobalExpanded(null);
|
||||
} else {
|
||||
const itemForStore: ItemListStateItemWithRequiredProperties & {
|
||||
imageId: null | string;
|
||||
} = {
|
||||
...itemListItem,
|
||||
imageId: (itemListItem as { imageId?: null | string }).imageId ?? null,
|
||||
};
|
||||
setGlobalExpanded({
|
||||
item: itemForStore,
|
||||
itemType,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onFavorite: ({
|
||||
|
||||
Reference in New Issue
Block a user