Detect custom css / js changes, no refresh

This commit is contained in:
shamoon 2023-09-10 07:39:36 -07:00
parent e17e47364a
commit 08e3164e84
2 changed files with 3 additions and 5 deletions

View File

@ -1,10 +1,8 @@
import useSWR from "swr" import useSWR from "swr"
export default function FileContent({ path, loadingValue, errorValue, emptyValue = '', refresh = 1500 }) { export default function FileContent({ path, loadingValue, errorValue, emptyValue = '' }) {
const fetcher = (url) => fetch(url).then((res) => res.text()) const fetcher = (url) => fetch(url).then((res) => res.text())
const { data, error, isLoading } = useSWR(`/api/config/${ path }`, fetcher, { const { data, error, isLoading } = useSWR(`/api/config/${ path }`, fetcher)
refreshInterval: refresh,
})
if (error) return (errorValue) if (error) return (errorValue)
if (isLoading) return (loadingValue) if (isLoading) return (loadingValue)

View File

@ -4,7 +4,7 @@ import { readFileSync } from "fs";
import checkAndCopyConfig, { CONF_DIR } from "utils/config/config"; import checkAndCopyConfig, { CONF_DIR } from "utils/config/config";
const configs = ["docker.yaml", "settings.yaml", "services.yaml", "bookmarks.yaml", "widgets.yaml"]; const configs = ["docker.yaml", "settings.yaml", "services.yaml", "bookmarks.yaml", "widgets.yaml", "custom.css", "custom.js"];
function hash(buffer) { function hash(buffer) {
const hashSum = createHash("sha256"); const hashSum = createHash("sha256");