forked from Mirrors/gomuks
web/roomlist: add title for pseudo-spaces
This commit is contained in:
parent
d0c35dda75
commit
43f25727e6
1 changed files with 9 additions and 8 deletions
|
@ -30,27 +30,28 @@ export interface FakeSpaceProps {
|
||||||
onClickUnread?: (evt: React.MouseEvent<HTMLDivElement> | null, space: Space | null) => void
|
onClickUnread?: (evt: React.MouseEvent<HTMLDivElement> | null, space: Space | null) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const getFakeSpaceIcon = (space: RoomListFilter | null): JSX.Element | null => {
|
const getFakeSpaceMeta = (space: RoomListFilter | null): [string | undefined, JSX.Element | null] => {
|
||||||
switch (space?.id) {
|
switch (space?.id) {
|
||||||
case undefined:
|
case undefined:
|
||||||
return <HomeIcon />
|
return ["Home", <HomeIcon />]
|
||||||
case "fi.mau.gomuks.direct_chats":
|
case "fi.mau.gomuks.direct_chats":
|
||||||
return <PersonIcon />
|
return ["Direct chats", <PersonIcon />]
|
||||||
case "fi.mau.gomuks.unreads":
|
case "fi.mau.gomuks.unreads":
|
||||||
return <NotificationsIcon />
|
return ["Unread chats", <NotificationsIcon />]
|
||||||
case "fi.mau.gomuks.space_orphans":
|
case "fi.mau.gomuks.space_orphans":
|
||||||
return <TagIcon />
|
return ["Rooms outside spaces", <TagIcon />]
|
||||||
default:
|
default:
|
||||||
return null
|
return [undefined, null]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const FakeSpace = ({ space, setSpace, isActive, onClickUnread }: FakeSpaceProps) => {
|
const FakeSpace = ({ space, setSpace, isActive, onClickUnread }: FakeSpaceProps) => {
|
||||||
const unreads = useEventAsState(space?.counts)
|
const unreads = useEventAsState(space?.counts)
|
||||||
const onClickUnreadWrapped = onClickUnread ? () => onClickUnread(null, space) : undefined
|
const onClickUnreadWrapped = onClickUnread ? () => onClickUnread(null, space) : undefined
|
||||||
return <div className={`space-entry ${isActive ? "active" : ""}`} onClick={() => setSpace(space)}>
|
const [title, icon] = getFakeSpaceMeta(space)
|
||||||
|
return <div className={`space-entry ${isActive ? "active" : ""}`} onClick={() => setSpace(space)} title={title}>
|
||||||
<UnreadCount counts={unreads} space={true} onClick={onClickUnreadWrapped} />
|
<UnreadCount counts={unreads} space={true} onClick={onClickUnreadWrapped} />
|
||||||
{getFakeSpaceIcon(space)}
|
{icon}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue