mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
unrender sidebar play queue when fullscreen player is open
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { lazy, Suspense, useCallback, useMemo, useRef, useState } from 'react';
|
import { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
// import { Group, Panel, Separator, useDefaultLayout } from 'react-resizable-panels';
|
// import { Group, Panel, Separator, useDefaultLayout } from 'react-resizable-panels';
|
||||||
import { Pane, SplitPane, usePersistence } from 'react-split-pane';
|
import { Pane, SplitPane, usePersistence } from 'react-split-pane';
|
||||||
@@ -12,6 +12,7 @@ import { Lyrics } from '/@/renderer/features/lyrics/lyrics';
|
|||||||
import { PlayQueue } from '/@/renderer/features/now-playing/components/play-queue';
|
import { PlayQueue } from '/@/renderer/features/now-playing/components/play-queue';
|
||||||
import { PlayQueueListControls } from '/@/renderer/features/now-playing/components/play-queue-list-controls';
|
import { PlayQueueListControls } from '/@/renderer/features/now-playing/components/play-queue-list-controls';
|
||||||
import {
|
import {
|
||||||
|
useFullScreenPlayerStore,
|
||||||
useGeneralSettings,
|
useGeneralSettings,
|
||||||
usePlaybackSettings,
|
usePlaybackSettings,
|
||||||
usePlayerSong,
|
usePlayerSong,
|
||||||
@@ -40,6 +41,8 @@ const ButterchurnVisualizer = lazy(() =>
|
|||||||
export const SidebarPlayQueue = () => {
|
export const SidebarPlayQueue = () => {
|
||||||
const tableRef = useRef<ItemListHandle | null>(null);
|
const tableRef = useRef<ItemListHandle | null>(null);
|
||||||
const [search, setSearch] = useState<string | undefined>(undefined);
|
const [search, setSearch] = useState<string | undefined>(undefined);
|
||||||
|
const { expanded: isFullScreenPlayerExpanded } = useFullScreenPlayerStore();
|
||||||
|
const [shouldRender, setShouldRender] = useState(!isFullScreenPlayerExpanded);
|
||||||
const {
|
const {
|
||||||
combinedLyricsAndVisualizer,
|
combinedLyricsAndVisualizer,
|
||||||
showLyricsInSidebar,
|
showLyricsInSidebar,
|
||||||
@@ -50,6 +53,23 @@ export const SidebarPlayQueue = () => {
|
|||||||
const showVisualizer = showVisualizerInSidebar && type === PlayerType.WEB && webAudio;
|
const showVisualizer = showVisualizerInSidebar && type === PlayerType.WEB && webAudio;
|
||||||
const showPanel = showLyricsInSidebar || showVisualizer;
|
const showPanel = showLyricsInSidebar || showVisualizer;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isFullScreenPlayerExpanded) {
|
||||||
|
// Immediately hide when fullscreen player opens
|
||||||
|
setShouldRender(false);
|
||||||
|
return undefined;
|
||||||
|
} else {
|
||||||
|
// Wait 500ms before re-rendering when fullscreen player closes to avoid performance issues
|
||||||
|
const timeoutId = setTimeout(() => {
|
||||||
|
setShouldRender(true);
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, [isFullScreenPlayerExpanded]);
|
||||||
|
|
||||||
const [defaultLayout, onLayoutChange] = usePersistence({
|
const [defaultLayout, onLayoutChange] = usePersistence({
|
||||||
debounce: 300,
|
debounce: 300,
|
||||||
key: 'sidebar-play-queue-container',
|
key: 'sidebar-play-queue-container',
|
||||||
@@ -149,6 +169,11 @@ export const SidebarPlayQueue = () => {
|
|||||||
[defaultLayout, orderedPanels],
|
[defaultLayout, orderedPanels],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Unmount when fullscreen player is open
|
||||||
|
if (!shouldRender) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack gap={0} h="100%" id="sidebar-play-queue-container" pos="relative" w="100%">
|
<Stack gap={0} h="100%" id="sidebar-play-queue-container" pos="relative" w="100%">
|
||||||
<PlayQueueListControls
|
<PlayQueueListControls
|
||||||
|
|||||||
Reference in New Issue
Block a user