2021-08-31 16:08:47 +00:00
|
|
|
import { useCallback } from "react";
|
2021-03-25 14:22:43 +00:00
|
|
|
import { useSystemSettings } from ".";
|
2021-08-31 16:08:47 +00:00
|
|
|
import { siteAddNotifications } from "../actions";
|
2021-03-25 14:22:43 +00:00
|
|
|
import { useReduxAction, useReduxStore } from "./base";
|
|
|
|
|
2021-05-09 03:22:24 +00:00
|
|
|
export function useNotification(id: string, timeout: number = 5000) {
|
2021-05-08 17:58:56 +00:00
|
|
|
const add = useReduxAction(siteAddNotifications);
|
2021-03-25 14:22:43 +00:00
|
|
|
|
|
|
|
return useCallback(
|
2021-08-14 12:59:08 +00:00
|
|
|
(msg: Omit<Server.Notification, "id" | "timeout">) => {
|
|
|
|
const notification: Server.Notification = {
|
2021-03-25 14:22:43 +00:00
|
|
|
...msg,
|
2021-05-09 03:22:24 +00:00
|
|
|
id,
|
|
|
|
timeout,
|
2021-03-25 14:22:43 +00:00
|
|
|
};
|
2021-05-09 03:22:24 +00:00
|
|
|
add([notification]);
|
2021-03-25 14:22:43 +00:00
|
|
|
},
|
2021-05-09 03:22:24 +00:00
|
|
|
[add, timeout, id]
|
2021-03-25 14:22:43 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useIsOffline() {
|
|
|
|
return useReduxStore((s) => s.site.offline);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useIsSonarrEnabled() {
|
2021-08-14 12:59:08 +00:00
|
|
|
const settings = useSystemSettings();
|
|
|
|
return settings.content?.general.use_sonarr ?? true;
|
2021-03-25 14:22:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function useIsRadarrEnabled() {
|
2021-08-14 12:59:08 +00:00
|
|
|
const settings = useSystemSettings();
|
|
|
|
return settings.content?.general.use_radarr ?? true;
|
2021-03-25 14:22:43 +00:00
|
|
|
}
|
2021-05-08 14:25:29 +00:00
|
|
|
|
|
|
|
export function useShowOnlyDesired() {
|
2021-08-14 12:59:08 +00:00
|
|
|
const settings = useSystemSettings();
|
|
|
|
return settings.content?.general.embedded_subs_show_desired ?? false;
|
2021-05-08 14:25:29 +00:00
|
|
|
}
|