blob: 05354572b0381a260d1566376ac904c1b3243121 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import { useCallback, useEffect } from "react";
import { useSystemSettings } from ".";
import { siteAddNotifications, siteChangeSidebar } from "../actions";
import { useReduxAction, useReduxStore } from "./base";
export function useNotification(id: string, timeout: number = 5000) {
const add = useReduxAction(siteAddNotifications);
return useCallback(
(msg: Omit<Server.Notification, "id" | "timeout">) => {
const notification: Server.Notification = {
...msg,
id,
timeout,
};
add([notification]);
},
[add, timeout, id]
);
}
export function useIsOffline() {
return useReduxStore((s) => s.site.offline);
}
export function useIsSonarrEnabled() {
const settings = useSystemSettings();
return settings.content?.general.use_sonarr ?? true;
}
export function useIsRadarrEnabled() {
const settings = useSystemSettings();
return settings.content?.general.use_radarr ?? true;
}
export function useShowOnlyDesired() {
const settings = useSystemSettings();
return settings.content?.general.embedded_subs_show_desired ?? false;
}
export function useSetSidebar(key: string) {
const update = useReduxAction(siteChangeSidebar);
useEffect(() => {
update(key);
}, [update, key]);
}
|