Merge branch 'v1.5.0' into feature/playlists/107

This commit is contained in:
MathieuG-P
2024-03-22 15:12:26 +01:00
59 changed files with 695 additions and 1024 deletions
@@ -0,0 +1,16 @@
import { useConstant } from "./use-constant.hook";
export function useWindowArgs<Key extends string>(...keys: Key[]): Record<Key, string|undefined> {
const getArgs = (...keys: Key[]) => {
const url = new URLSearchParams(window.location.search);
const result = {} as Record<Key, string>;
keys.forEach(key => {
result[key] = url.get(key) || undefined;
});
return result;
}
return useConstant(() => getArgs(...keys));
}
@@ -0,0 +1,17 @@
import { IpcService } from "renderer/services/ipc.service";
import { useService } from "./use-service.hook";
import { useConstant } from "./use-constant.hook";
import { lastValueFrom } from "rxjs";
export function useWindowControls() {
const ipc = useService(IpcService);
const { close, maximise, minimise, unmaximise } = useConstant(() => ({
close: () => lastValueFrom(ipc.sendV2("close-window")),
maximise: () => lastValueFrom(ipc.sendV2("maximise-window")),
minimise: () => lastValueFrom(ipc.sendV2("minimise-window")),
unmaximise: () => lastValueFrom(ipc.sendV2("unmaximise-window"))
}));
return { close, maximise, minimise, unmaximise };
}