2021-06-10 02:20:23 +00:00
|
|
|
import { useCallback, useMemo } from "react";
|
2021-03-29 11:16:45 +00:00
|
|
|
import { useHistory } from "react-router";
|
2021-05-08 14:25:29 +00:00
|
|
|
import { getBaseUrl } from ".";
|
2021-03-25 14:22:43 +00:00
|
|
|
|
|
|
|
export function useBaseUrl(slash: boolean = false) {
|
2021-05-08 14:25:29 +00:00
|
|
|
return useMemo(() => getBaseUrl(slash), [slash]);
|
2021-03-25 14:22:43 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 11:16:45 +00:00
|
|
|
export function useGotoHomepage() {
|
|
|
|
const history = useHistory();
|
|
|
|
return useCallback(() => history.push("/"), [history]);
|
|
|
|
}
|
|
|
|
|
2021-03-25 14:22:43 +00:00
|
|
|
export function useCanUpdateInject() {
|
2021-08-14 12:59:08 +00:00
|
|
|
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() {
|
2021-08-14 12:59:08 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|