2023-03-31 06:22:04 -07:00
|
|
|
import isElectron from 'is-electron';
|
2023-02-07 22:47:23 -08:00
|
|
|
import { useLocation } from 'react-router';
|
2025-05-18 14:03:18 -07:00
|
|
|
|
2023-02-07 22:47:23 -08:00
|
|
|
import { AppRoute } from '/@/renderer/router/routes';
|
2025-05-18 14:03:18 -07:00
|
|
|
import { useGeneralSettings, useSidebarRightExpanded, useWindowSettings } from '/@/renderer/store';
|
2025-05-20 19:23:36 -07:00
|
|
|
import { Platform } from '/@/shared/types/types';
|
2022-12-19 15:59:14 -08:00
|
|
|
|
|
|
|
|
export const useShouldPadTitlebar = () => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const location = useLocation();
|
|
|
|
|
const isSidebarExpanded = useSidebarRightExpanded();
|
|
|
|
|
const isQueuePage = location.pathname === AppRoute.NOW_PLAYING;
|
|
|
|
|
const { sideQueueType } = useGeneralSettings();
|
|
|
|
|
const { windowBarStyle } = useWindowSettings();
|
2022-12-19 15:59:14 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const conditions = [
|
|
|
|
|
isElectron(),
|
|
|
|
|
windowBarStyle === Platform.WEB,
|
|
|
|
|
!(isSidebarExpanded && sideQueueType === 'sideQueue' && !isQueuePage),
|
|
|
|
|
];
|
2023-02-07 22:47:23 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const shouldPadTitlebar = conditions.every((condition) => condition);
|
2023-03-28 23:59:51 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
return shouldPadTitlebar;
|
2022-12-19 15:59:14 -08:00
|
|
|
};
|