diff --git a/src/index.html b/src/index.html
index 4a80a66..730294f 100644
--- a/src/index.html
+++ b/src/index.html
@@ -2,7 +2,7 @@
- stream.t-juice.club
+
diff --git a/src/js/app.tsx b/src/js/app.tsx
index dbb607f..69c93e6 100644
--- a/src/js/app.tsx
+++ b/src/js/app.tsx
@@ -9,11 +9,27 @@ interface AppProps {
api: MinistreamApiClient
}
+const titleKey = "ministream.title"
+
+function setTitleFromLocalstorage() {
+ var title = localStorage.getItem(titleKey)
+ if (title) {
+ setTitle(title)
+ }
+}
+
+function setTitle(title: string) {
+ const el = document.querySelector('title')
+ if (el) {
+ el.textContent = title
+ }
+}
+
export function App({ api }: AppProps) {
const [streamList, setStreamList] = useState([])
const [selectedStream, setSelectedStream] = useState(null)
- const updateSelect = (item: string) => {
+ const updateSelect = (item: string | null) => {
setSelectedStream(item)
}
@@ -33,19 +49,8 @@ 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) {
+ api.siteInfo().then((info) => {
+ if (info.siteName != document.title) {
setTitle(info.siteName)
localStorage.setItem(titleKey, info.siteName)
}
@@ -60,11 +65,11 @@ export function App({ api }: AppProps) {
useEffect(() => {
updateStreamList()
}, [])
+
useEffect(() => {
updateTitle()
}, [])
-
return (
<>
)
}
\ No newline at end of file
diff --git a/src/js/menu.tsx b/src/js/menu.tsx
index 59d5dc0..ec8f87f 100644
--- a/src/js/menu.tsx
+++ b/src/js/menu.tsx
@@ -1,7 +1,7 @@
import { createRoot } from "react-dom/client";
import React from "react";
-type StreamSelectCallback = (selected: string) => void
+type StreamSelectCallback = (selected: string | null) => void
interface MenuProps {
items: string[]
@@ -10,6 +10,7 @@ interface MenuProps {
}
export function Menu({ items, selectedItem, selectCallback }: MenuProps) {
+ const title = document.title
const menuitems = () => {
return (
<>
@@ -28,7 +29,9 @@ export function Menu({ items, selectedItem, selectCallback }: MenuProps) {
return (