mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
attempt to fix playqueue initial height issue
This commit is contained in:
@@ -41,6 +41,7 @@ export const PlayQueue = forwardRef<ItemListHandle, QueueProps>(({ listKey, sear
|
||||
|
||||
const isFetching = useIsPlayerFetching();
|
||||
const tableRef = useRef<ItemListHandle>(null);
|
||||
const previousSongCountRef = useRef<number>(0);
|
||||
const mergedRef = useMergedRef(ref, tableRef);
|
||||
const { getQueue } = usePlayerActions();
|
||||
const queueType = usePlayerQueueType();
|
||||
@@ -49,6 +50,7 @@ export const PlayQueue = forwardRef<ItemListHandle, QueueProps>(({ listKey, sear
|
||||
|
||||
const [data, setData] = useState<QueueSong[]>([]);
|
||||
const [groups, setGroups] = useState<TableGroupHeader[]>([]);
|
||||
const [containerKey, setContainerKey] = useState<string>(() => Math.random().toString(36));
|
||||
|
||||
useEffect(() => {
|
||||
const setQueue = () => {
|
||||
@@ -105,6 +107,17 @@ export const PlayQueue = forwardRef<ItemListHandle, QueueProps>(({ listKey, sear
|
||||
};
|
||||
}, [getQueue, queueType, tableRef]);
|
||||
|
||||
useEffect(() => {
|
||||
const currentCount = data.length;
|
||||
const previousCount = previousSongCountRef.current;
|
||||
|
||||
if (previousCount === 0 && currentCount > 0) {
|
||||
setContainerKey(Math.random().toString(36));
|
||||
}
|
||||
|
||||
previousSongCountRef.current = currentCount;
|
||||
}, [data.length]);
|
||||
|
||||
const filteredData: QueueSong[] = useMemo(() => {
|
||||
if (debouncedSearchTerm) {
|
||||
const searched = searchLibraryItems(data, debouncedSearchTerm, LibraryItem.SONG);
|
||||
@@ -128,7 +141,7 @@ export const PlayQueue = forwardRef<ItemListHandle, QueueProps>(({ listKey, sear
|
||||
const currentSongUniqueId = currentSong?._uniqueId;
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<div className={styles.container} key={containerKey}>
|
||||
<LoadingOverlay pos="absolute" visible={isFetching} />
|
||||
<ItemTableList
|
||||
activeRowId={currentSongUniqueId}
|
||||
|
||||
Reference in New Issue
Block a user