forked from Shiloh/remnantchat
feat: show user name to self
This commit is contained in:
parent
59a93c6fd0
commit
c2cd21672a
@ -49,7 +49,7 @@ function Bootstrap({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Router>
|
<Router>
|
||||||
<Shell>
|
<Shell userPeerId={userId}>
|
||||||
{hasLoadedSettings ? (
|
{hasLoadedSettings ? (
|
||||||
<Routes>
|
<Routes>
|
||||||
{['/', '/index.html'].map(path => (
|
{['/', '/index.html'].map(path => (
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
import Typography, { TypographyProps } from '@mui/material/Typography'
|
||||||
import { funAnimalName } from 'fun-animal-names'
|
import { funAnimalName } from 'fun-animal-names'
|
||||||
|
|
||||||
interface PeerNameDisplayProps {
|
interface PeerNameDisplayProps extends TypographyProps {
|
||||||
children: string
|
children: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PeerNameDisplay = ({ children }: PeerNameDisplayProps) => {
|
export const PeerNameDisplay = ({
|
||||||
return <>{funAnimalName(children)}</>
|
children,
|
||||||
|
...rest
|
||||||
|
}: PeerNameDisplayProps) => {
|
||||||
|
return <Typography {...rest}>{funAnimalName(children)}</Typography>
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@ import { MemoryRouter as Router } from 'react-router-dom'
|
|||||||
|
|
||||||
import { Shell, ShellProps } from './Shell'
|
import { Shell, ShellProps } from './Shell'
|
||||||
|
|
||||||
const ShellStub = (overrides: ShellProps = {}) => {
|
const ShellStub = (overrides: Partial<ShellProps> = {}) => {
|
||||||
return (
|
return (
|
||||||
<Router>
|
<Router>
|
||||||
<Shell {...overrides} />
|
<Shell userPeerId="abc123" {...overrides} />
|
||||||
</Router>
|
</Router>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,11 @@ import Brightness7Icon from '@mui/icons-material/Brightness7'
|
|||||||
|
|
||||||
import { ShellContext } from 'ShellContext'
|
import { ShellContext } from 'ShellContext'
|
||||||
import { AlertOptions } from 'models/shell'
|
import { AlertOptions } from 'models/shell'
|
||||||
|
import { PeerNameDisplay } from 'components/PeerNameDisplay'
|
||||||
|
|
||||||
export interface ShellProps extends PropsWithChildren {}
|
export interface ShellProps extends PropsWithChildren {
|
||||||
|
userPeerId: string
|
||||||
|
}
|
||||||
|
|
||||||
const drawerWidth = 240
|
const drawerWidth = 240
|
||||||
|
|
||||||
@ -97,7 +100,7 @@ const DrawerHeader = styled('div')(({ theme }) => ({
|
|||||||
justifyContent: 'flex-end',
|
justifyContent: 'flex-end',
|
||||||
}))
|
}))
|
||||||
|
|
||||||
export const Shell = ({ children }: ShellProps) => {
|
export const Shell = ({ children, userPeerId }: ShellProps) => {
|
||||||
const [isAlertShowing, setIsAlertShowing] = useState(false)
|
const [isAlertShowing, setIsAlertShowing] = useState(false)
|
||||||
const [isDrawerOpen, setIsDrawerOpen] = useState(false)
|
const [isDrawerOpen, setIsDrawerOpen] = useState(false)
|
||||||
const [doShowPeers, setDoShowPeers] = useState(false)
|
const [doShowPeers, setDoShowPeers] = useState(false)
|
||||||
@ -247,6 +250,22 @@ export const Shell = ({ children }: ShellProps) => {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</DrawerHeader>
|
</DrawerHeader>
|
||||||
<Divider />
|
<Divider />
|
||||||
|
<ListItem disablePadding>
|
||||||
|
<ListItemText
|
||||||
|
sx={{
|
||||||
|
padding: '1em 1.5em',
|
||||||
|
}}
|
||||||
|
primary={
|
||||||
|
<>
|
||||||
|
<Typography>Your user name: </Typography>
|
||||||
|
<PeerNameDisplay sx={{ fontWeight: 'bold' }}>
|
||||||
|
{userPeerId}
|
||||||
|
</PeerNameDisplay>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</ListItem>
|
||||||
|
<Divider />
|
||||||
<List role="navigation">
|
<List role="navigation">
|
||||||
<Link to="/">
|
<Link to="/">
|
||||||
<ListItem disablePadding>
|
<ListItem disablePadding>
|
||||||
|
Loading…
Reference in New Issue
Block a user