mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 14:35:41 +00:00
7a7a9f5e6b
111 of 122 top-level src/utils/ files move into 16 topic folders (audio, cache, cover, share, server, playback, playlist, deviceSync, waveform, mix, format, export, changelog, ui, perf, componentHelpers). True singletons with no cluster stay at the utils/ root. Pure file-move: a path-aware codemod rewrote 539 relative-import specifiers across 275 files; no logic touched. The hot-path coverage gate list (.github/frontend-hot-path-files.txt) is updated to the new paths for the 11 gated utils files — a mechanical consequence of the move, not a CI change. tsc is green.
53 lines
1.9 KiB
TypeScript
53 lines
1.9 KiB
TypeScript
import { useEffect } from 'react';
|
|
import { invoke } from '@tauri-apps/api/core';
|
|
import { useAuthStore } from '../store/authStore';
|
|
import { IS_LINUX } from '../utils/platform';
|
|
import {
|
|
EXPANDED_SIZE, EXPANDED_MIN, readStoredExpandedHeight,
|
|
} from '../utils/componentHelpers/miniPlayerHelpers';
|
|
|
|
/** Three window-bound setup effects bundled together:
|
|
* - Linux WebKitGTK smooth-scroll per-window (re-applies after auth hydrates
|
|
* so preloaded/hidden mini matches the Settings toggle).
|
|
* - Initial expanded-size restore: Rust always builds the window at the
|
|
* collapsed size, so on cold start with queueOpen=true we resize once.
|
|
* - Always-on-top reapply on mount and on focus: WMs silently drop the
|
|
* constraint after Hide/Show cycles, so we re-assert it whenever the user
|
|
* actually brings the window to the foreground. */
|
|
export function useMiniWindowSetup(alwaysOnTop: boolean, initialQueueOpen: boolean) {
|
|
useEffect(() => {
|
|
if (!IS_LINUX) return;
|
|
const apply = () => {
|
|
invoke('set_linux_webkit_smooth_scrolling', {
|
|
enabled: useAuthStore.getState().linuxWebkitKineticScroll,
|
|
}).catch(() => {});
|
|
};
|
|
apply();
|
|
return useAuthStore.persist.onFinishHydration(() => {
|
|
apply();
|
|
});
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
if (!initialQueueOpen) return;
|
|
invoke('resize_mini_player', {
|
|
width: EXPANDED_SIZE.w,
|
|
height: readStoredExpandedHeight(),
|
|
minWidth: EXPANDED_MIN.w,
|
|
minHeight: EXPANDED_MIN.h,
|
|
}).catch(() => {});
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
invoke('set_mini_player_always_on_top', { onTop: alwaysOnTop }).catch(() => {});
|
|
const reapply = () => {
|
|
if (alwaysOnTop) {
|
|
invoke('set_mini_player_always_on_top', { onTop: true }).catch(() => {});
|
|
}
|
|
};
|
|
window.addEventListener('focus', reapply);
|
|
return () => window.removeEventListener('focus', reapply);
|
|
}, [alwaysOnTop]);
|
|
}
|