diff --git a/src/js/api.ts b/src/js/api.ts index 137675c..3021467 100644 --- a/src/js/api.ts +++ b/src/js/api.ts @@ -61,9 +61,9 @@ export class MinistreamApiClient { } async siteInfo(): Promise { - var url = "/api/info" + var url = "/api/siteinfo" if (this.ENV !== "production") { - url = "http://localhost:8080/api/info" + url = "http://localhost:8080/api/siteinfo" } const resp = await fetch(url, diff --git a/src/js/app.tsx b/src/js/app.tsx index 54806f0..dbb607f 100644 --- a/src/js/app.tsx +++ b/src/js/app.tsx @@ -32,13 +32,37 @@ export function App({ api }: AppProps) { }) } + const updateTitle = () => { + const titleKey = "ministream.title" + var title = localStorage.getItem(titleKey) + const setTitle = (title: string) => { + const el = document.querySelector('title') + if (el) { + el.textContent = title + } + } + if (title) { + setTitle(title) + } + api.siteInfo().then((info) => { + if (info.siteName != title) { + setTitle(info.siteName) + localStorage.setItem(titleKey, info.siteName) + } + }) + return + } + setInterval(() => { updateStreamList() }, 10000) useEffect(() => { updateStreamList() - },[]) + }, []) + useEffect(() => { + updateTitle() + }, []) return ( @@ -57,5 +81,5 @@ const rootElement = document.getElementById("app"); if (rootElement) { const root = createRoot(rootElement); const api = new MinistreamApiClient() - root.render() + root.render() } \ No newline at end of file