mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
fix internalState on expanded album item
This commit is contained in:
@@ -11,6 +11,7 @@ import { useDefaultItemListControls } from '/@/renderer/components/item-list/hel
|
||||
import {
|
||||
ItemListStateActions,
|
||||
ItemListStateItem,
|
||||
useItemDraggingState,
|
||||
useItemListState,
|
||||
useItemSelectionState,
|
||||
} from '/@/renderer/components/item-list/helpers/item-list-state';
|
||||
@@ -30,7 +31,6 @@ import { LibraryItem, Song } from '/@/shared/types/domain-types';
|
||||
import { DragOperation, DragTarget, DragTargetMap } from '/@/shared/types/drag-and-drop';
|
||||
|
||||
interface AlbumTracksTableProps {
|
||||
internalState?: ItemListStateActions;
|
||||
isDark?: boolean;
|
||||
serverId: string;
|
||||
songs?: Array<{
|
||||
@@ -57,6 +57,7 @@ interface TrackRowProps {
|
||||
const TrackRow = ({ controls, internalState, serverId, song }: TrackRowProps) => {
|
||||
const rowId = internalState.extractRowId(song);
|
||||
const isSelected = useItemSelectionState(internalState, rowId);
|
||||
const isDraggingState = useItemDraggingState(internalState, rowId);
|
||||
|
||||
const songWithMetadata = {
|
||||
...song,
|
||||
@@ -101,7 +102,7 @@ const TrackRow = ({ controls, internalState, serverId, song }: TrackRowProps) =>
|
||||
isEnabled: true,
|
||||
});
|
||||
|
||||
const isDragging = internalState.isDragging(song.id) || isDraggingLocal;
|
||||
const isDragging = isDraggingState || isDraggingLocal;
|
||||
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const mergedRef = useMergedRef(containerRef, dragRef);
|
||||
@@ -134,12 +135,7 @@ const TrackRow = ({ controls, internalState, serverId, song }: TrackRowProps) =>
|
||||
);
|
||||
};
|
||||
|
||||
const AlbumTracksTable = ({
|
||||
internalState: parentInternalState,
|
||||
isDark,
|
||||
serverId,
|
||||
songs,
|
||||
}: AlbumTracksTableProps) => {
|
||||
const AlbumTracksTable = ({ isDark, serverId, songs }: AlbumTracksTableProps) => {
|
||||
const getDataFn = useCallback(() => songs || [], [songs]);
|
||||
|
||||
const extractRowId = useCallback((item: unknown) => {
|
||||
@@ -149,9 +145,9 @@ const AlbumTracksTable = ({
|
||||
return undefined;
|
||||
}, []);
|
||||
|
||||
// Use parent internalState if available, otherwise create a local one
|
||||
const localInternalState = useItemListState(getDataFn, extractRowId);
|
||||
const internalState = parentInternalState || localInternalState;
|
||||
// Always use a local state for tracks - tracks are separate entities from albums
|
||||
// and need their own selection state. The parentInternalState is for album-level operations.
|
||||
const internalState = useItemListState(getDataFn, extractRowId);
|
||||
|
||||
const controls = useDefaultItemListControls();
|
||||
|
||||
@@ -262,7 +258,6 @@ export const ExpandedAlbumListItem = ({ internalState, item }: ExpandedAlbumList
|
||||
</Group>
|
||||
</div>
|
||||
<AlbumTracksTable
|
||||
internalState={internalState}
|
||||
isDark={color.isDark}
|
||||
serverId={item._serverId}
|
||||
songs={data?.songs}
|
||||
|
||||
Reference in New Issue
Block a user