mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-19 18:13:41 -05:00
web/roomlist: close room when switching space
This commit is contained in:
parent
7afcc37326
commit
d0c35dda75
3 changed files with 14 additions and 3 deletions
|
@ -77,7 +77,7 @@ export class StateStore {
|
|||
readonly spaceEdges: Map<RoomID, SpaceEdgeStore> = new Map()
|
||||
readonly spaceOrphans = new SpaceOrphansSpace(this)
|
||||
readonly directChatsSpace = new DirectChatSpace()
|
||||
readonly unreadsSpace = new UnreadsSpace()
|
||||
readonly unreadsSpace = new UnreadsSpace(this)
|
||||
readonly pseudoSpaces = [
|
||||
this.spaceOrphans,
|
||||
this.directChatsSpace,
|
||||
|
|
|
@ -79,8 +79,13 @@ export class DirectChatSpace extends Space {
|
|||
export class UnreadsSpace extends Space {
|
||||
id = "fi.mau.gomuks.unreads"
|
||||
|
||||
constructor(private parent: StateStore) {
|
||||
super()
|
||||
}
|
||||
|
||||
include(room: RoomListEntry): boolean {
|
||||
return Boolean(room.unread_messages
|
||||
return Boolean(room.room_id === this.parent.activeRoomID
|
||||
|| room.unread_messages
|
||||
|| room.unread_notifications
|
||||
|| room.unread_highlights
|
||||
|| room.marked_unread)
|
||||
|
|
|
@ -49,7 +49,13 @@ const RoomList = ({ activeRoomID }: RoomListProps) => {
|
|||
const setSpace = useCallback((space: RoomListFilter | null) => {
|
||||
directSetSpace(space)
|
||||
client.store.currentRoomListFilter = space
|
||||
}, [client])
|
||||
if (client.store.activeRoomID && space) {
|
||||
const entry = client.store.rooms.get(client.store.activeRoomID)?.roomListEntry
|
||||
if (entry && !space.include(entry)) {
|
||||
mainScreen.setActiveRoom(null)
|
||||
}
|
||||
}
|
||||
}, [client, mainScreen])
|
||||
const onClickSpace = useCallback((evt: React.MouseEvent<HTMLDivElement>) => {
|
||||
const store = client.store.getSpaceStore(evt.currentTarget.getAttribute("data-target-space")!)
|
||||
setSpace(store)
|
||||
|
|
Loading…
Add table
Reference in a new issue