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