diff --git a/src/Bootstrap.tsx b/src/Bootstrap.tsx
index 27cc711..4946466 100644
--- a/src/Bootstrap.tsx
+++ b/src/Bootstrap.tsx
@@ -1,9 +1,13 @@
-import { useEffect, useState } from 'react'
+import { useEffect, useMemo, useState } from 'react'
import { Routes, Route } from 'react-router-dom'
import { v4 as uuid } from 'uuid'
import localforage from 'localforage'
+import AppBar from '@mui/material/AppBar'
+import Toolbar from '@mui/material/Toolbar'
import Box from '@mui/material/Box'
+import Typography from '@mui/material/Typography'
+import { ShellContext } from 'ShellContext'
import { Home } from 'pages/Home/'
import { PublicRoom } from 'pages/PublicRoom/'
import { UserSettings } from 'models/settings'
@@ -24,6 +28,9 @@ function Bootstrap({
const [hasLoadedSettings, setHasLoadedSettings] = useState(false)
const [settings, setSettings] = useState({ userId: getUuid() })
const { userId } = settings
+ const [title, setTitle] = useState('')
+
+ const shellContextValue = useMemo(() => ({ setTitle }), [setTitle])
useEffect(() => {
;(async () => {
@@ -48,19 +55,29 @@ function Bootstrap({
}, [hasLoadedSettings, persistedStorage, settings, userId])
return (
-
- {hasLoadedSettings ? (
-
- {['/', '/index.html'].map(path => (
- } />
- ))}
- }
- />
-
- ) : null}
-
+
+
+
+
+ {title}
+
+
+ {hasLoadedSettings ? (
+
+ {['/', '/index.html'].map(path => (
+ } />
+ ))}
+ }
+ />
+
+ ) : null}
+
+
)
}
diff --git a/src/ShellContext.ts b/src/ShellContext.ts
new file mode 100644
index 0000000..21966cb
--- /dev/null
+++ b/src/ShellContext.ts
@@ -0,0 +1,9 @@
+import { createContext, Dispatch, SetStateAction } from 'react'
+
+interface ShellContextProps {
+ setTitle: Dispatch>
+}
+
+export const ShellContext = createContext({
+ setTitle: () => {},
+})
diff --git a/src/components/Room/Room.tsx b/src/components/Room/Room.tsx
index 8800479..54b6344 100644
--- a/src/components/Room/Room.tsx
+++ b/src/components/Room/Room.tsx
@@ -2,7 +2,6 @@ import React, { useState } from 'react'
import { v4 as uuid } from 'uuid'
import Box from '@mui/material/Box'
import FormControl from '@mui/material/FormControl'
-import Typography from '@mui/material/Typography'
import Stack from '@mui/material/Stack'
import TextField from '@mui/material/TextField'
import Fab from '@mui/material/Fab'
@@ -99,7 +98,6 @@ export function Room({
return (
- Room ID: {roomId}
{
+ setTitle('Chitchatter')
+ }, [setTitle])
+
const handleRoomNameChange = (event: React.ChangeEvent) => {
const { value } = event.target
setRoomName(value)
@@ -23,8 +30,7 @@ export function Home() {
return (
-
- chitchatter
+
This is a communication tool that is free, open source, and designed
for maximum security. All communication between you and your online
diff --git a/src/pages/PublicRoom/PublicRoom.tsx b/src/pages/PublicRoom/PublicRoom.tsx
index d13a5d8..12cbed6 100644
--- a/src/pages/PublicRoom/PublicRoom.tsx
+++ b/src/pages/PublicRoom/PublicRoom.tsx
@@ -1,11 +1,20 @@
+import { useContext, useEffect } from 'react'
import { Room } from 'components/Room'
import { useParams } from 'react-router-dom'
+import { ShellContext } from 'ShellContext'
+
interface PublicRoomProps {
userId: string
}
export function PublicRoom({ userId }: PublicRoomProps) {
const { roomId = '' } = useParams()
+ const { setTitle } = useContext(ShellContext)
+
+ useEffect(() => {
+ setTitle(`Room: ${roomId}`)
+ }, [roomId, setTitle])
+
return
}