Files
Toju/src/app/features/room/chat-room/chat-room.component.ts
2026-03-02 00:13:34 +01:00

70 lines
2.1 KiB
TypeScript

import { Component, inject, signal } from '@angular/core';
import { Router } from '@angular/router';
import { CommonModule } from '@angular/common';
import { Store } from '@ngrx/store';
import { NgIcon, provideIcons } from '@ng-icons/core';
import {
lucideHash,
lucideSettings,
lucideUsers,
lucideMenu,
lucideX,
lucideChevronLeft,
} from '@ng-icons/lucide';
import { ChatMessagesComponent } from '../../chat/chat-messages.component';
import { UserListComponent } from '../../chat/user-list.component';
import { ScreenShareViewerComponent } from '../../voice/screen-share-viewer/screen-share-viewer.component';
import { AdminPanelComponent } from '../../admin/admin-panel/admin-panel.component';
import { RoomsSidePanelComponent } from '../rooms-side-panel/rooms-side-panel.component';
import { selectCurrentRoom, selectActiveChannelId, selectTextChannels } from '../../../store/rooms/rooms.selectors';
import { selectIsCurrentUserAdmin } from '../../../store/users/users.selectors';
type SidebarPanel = 'rooms' | 'users' | 'admin' | null;
@Component({
selector: 'app-chat-room',
standalone: true,
imports: [
CommonModule,
NgIcon,
ChatMessagesComponent,
ScreenShareViewerComponent,
RoomsSidePanelComponent,
AdminPanelComponent,
],
viewProviders: [
provideIcons({
lucideHash,
lucideSettings,
lucideUsers,
lucideMenu,
lucideX,
lucideChevronLeft,
}),
],
templateUrl: './chat-room.component.html',
})
export class ChatRoomComponent {
private store = inject(Store);
private router = inject(Router);
showMenu = signal(false);
showAdminPanel = signal(false);
currentRoom = this.store.selectSignal(selectCurrentRoom);
isAdmin = this.store.selectSignal(selectIsCurrentUserAdmin);
activeChannelId = this.store.selectSignal(selectActiveChannelId);
textChannels = this.store.selectSignal(selectTextChannels);
get activeChannelName(): string {
const id = this.activeChannelId();
const ch = this.textChannels().find(c => c.id === id);
return ch ? ch.name : id;
}
toggleAdminPanel() {
this.showAdminPanel.update(v => !v);
}
}