bazarr/frontend/src/utilites/hooks.ts

29 lines
756 B
TypeScript
Raw Normal View History

import { useCallback, useMemo } from "react";
import { useHistory } from "react-router";
import { getBaseUrl } from ".";
2021-03-25 14:22:43 +00:00
export function useBaseUrl(slash: boolean = false) {
return useMemo(() => getBaseUrl(slash), [slash]);
2021-03-25 14:22:43 +00:00
}
export function useGotoHomepage() {
const history = useHistory();
return useCallback(() => history.push("/"), [history]);
}
2021-03-25 14:22:43 +00:00
export function useCanUpdateInject() {
if (process.env.NODE_ENV !== "production") {
2021-03-25 14:22:43 +00:00
return process.env["REACT_APP_CAN_UPDATE"] === "true";
} else {
return window.Bazarr.canUpdate;
}
}
export function useHasUpdateInject() {
if (process.env.NODE_ENV !== "production") {
2021-03-25 14:22:43 +00:00
return process.env["REACT_APP_HAS_UPDATE"] === "true";
} else {
return window.Bazarr.hasUpdate;
}
}