From 9a173792a455a02cdbe6676967bbf9ffc806547c Mon Sep 17 00:00:00 2001 From: Myx Date: Thu, 19 Mar 2026 03:48:41 +0100 Subject: [PATCH] Fix users list to only show server users --- .../rooms-side-panel.component.html | 8 +-- .../rooms-side-panel.component.ts | 61 ++++++++++++++----- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/src/app/features/room/rooms-side-panel/rooms-side-panel.component.html b/src/app/features/room/rooms-side-panel/rooms-side-panel.component.html index f3dd53d..4795511 100644 --- a/src/app/features/room/rooms-side-panel/rooms-side-panel.component.html +++ b/src/app/features/room/rooms-side-panel/rooms-side-panel.component.html @@ -261,11 +261,11 @@ } - @if (onlineUsersFiltered().length > 0) { + @if (onlineRoomUsers().length > 0) {
-

Online - {{ onlineUsersFiltered().length }}

+

Online - {{ onlineRoomUsers().length }}

- @for (user of onlineUsersFiltered(); track user.id) { + @for (user of onlineRoomUsers(); track user.id) {
- @if (onlineUsersFiltered().length === 0 && offlineRoomMembers().length === 0) { + @if (onlineRoomUsers().length === 0 && offlineRoomMembers().length === 0) {

No other users in this server

diff --git a/src/app/features/room/rooms-side-panel/rooms-side-panel.component.ts b/src/app/features/room/rooms-side-panel/rooms-side-panel.component.ts index 41f82a7..2c23978 100644 --- a/src/app/features/room/rooms-side-panel/rooms-side-panel.component.ts +++ b/src/app/features/room/rooms-side-panel/rooms-side-panel.component.ts @@ -104,15 +104,30 @@ export class RoomsSidePanelComponent { textChannels = this.store.selectSignal(selectTextChannels); voiceChannels = this.store.selectSignal(selectVoiceChannels); roomMembers = computed(() => this.currentRoom()?.members ?? []); - offlineRoomMembers = computed(() => { - const current = this.currentUser(); - const onlineIds = new Set(this.onlineUsers().map((user) => user.oderId || user.id)); + roomMemberIdentifiers = computed(() => { + const identifiers = new Set(); - if (current) { - onlineIds.add(current.oderId || current.id); + for (const member of this.roomMembers()) { + this.addIdentifiers(identifiers, member); } - return this.roomMembers().filter((member) => !onlineIds.has(this.roomMemberKey(member))); + return identifiers; + }); + onlineRoomUsers = computed(() => { + const memberIdentifiers = this.roomMemberIdentifiers(); + + return this.onlineUsers().filter((user) => !this.isCurrentUserIdentity(user) && this.matchesIdentifiers(memberIdentifiers, user)); + }); + offlineRoomMembers = computed(() => { + const onlineIdentifiers = new Set(); + + for (const user of this.onlineRoomUsers()) { + this.addIdentifiers(onlineIdentifiers, user); + } + + this.addIdentifiers(onlineIdentifiers, this.currentUser()); + + return this.roomMembers().filter((member) => !this.matchesIdentifiers(onlineIdentifiers, member)); }); knownUserCount = computed(() => { const memberIds = new Set( @@ -151,18 +166,36 @@ export class RoomsSidePanelComponent { volumeMenuPeerId = signal(''); volumeMenuDisplayName = signal(''); - onlineUsersFiltered() { - const current = this.currentUser(); - const currentId = current?.id; - const currentOderId = current?.oderId; - - return this.onlineUsers().filter((user) => user.id !== currentId && user.oderId !== currentOderId); - } - private roomMemberKey(member: RoomMember): string { return member.oderId || member.id; } + private addIdentifiers(identifiers: Set, entity: { id?: string; oderId?: string } | null | undefined): void { + if (!entity) + return; + + if (entity.id) { + identifiers.add(entity.id); + } + + if (entity.oderId) { + identifiers.add(entity.oderId); + } + } + + private matchesIdentifiers(identifiers: Set, entity: { id?: string; oderId?: string }): boolean { + return !!((entity.id && identifiers.has(entity.id)) || (entity.oderId && identifiers.has(entity.oderId))); + } + + private isCurrentUserIdentity(entity: { id?: string; oderId?: string }): boolean { + const current = this.currentUser(); + + return !!current && ( + (typeof entity.id === 'string' && entity.id === current.id) + || (typeof entity.oderId === 'string' && entity.oderId === current.oderId) + ); + } + canManageChannels(): boolean { const room = this.currentRoom(); const user = this.currentUser();