mirror of
https://github.com/AzuraCast/AzuraCast.git
synced 2024-06-13 12:46:41 +00:00
39 lines
749 B
JavaScript
39 lines
749 B
JavaScript
import {useAxios} from "~/vendor/axios";
|
|
|
|
export const mayNeedRestartProps = {
|
|
restartStatusUrl: {
|
|
type: String,
|
|
required: true
|
|
}
|
|
};
|
|
|
|
export function useNeedsRestart() {
|
|
const needsRestart = () => {
|
|
document.dispatchEvent(new CustomEvent("station-needs-restart"));
|
|
}
|
|
|
|
return {
|
|
needsRestart
|
|
};
|
|
}
|
|
|
|
export function useMayNeedRestart(restartStatusUrl) {
|
|
const {needsRestart} = useNeedsRestart();
|
|
const {axios} = useAxios();
|
|
|
|
const mayNeedRestart = () => {
|
|
axios.get(restartStatusUrl).then((resp) => {
|
|
if (resp.data.needs_restart) {
|
|
needsRestart();
|
|
}
|
|
});
|
|
}
|
|
|
|
return {
|
|
needsRestart,
|
|
mayNeedRestart
|
|
}
|
|
}
|
|
|
|
|