2026-07-18 22:22:54 +00:00
|
|
|
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
|
|
|
|
import {Subscription} from 'rxjs';
|
|
|
|
|
import {ChatService} from '@pages/altitude/chat/service/chat.service';
|
2026-07-18 22:59:04 +00:00
|
|
|
import {HeaderComponent} from '@header/header.component';
|
|
|
|
|
import {MiniMessageInteractionService} from '@pages/altitude/chat/mini-message/mini-message-interaction.service';
|
2026-07-19 15:12:03 +00:00
|
|
|
import {FullSizeComponent} from '@shared-components/full-size/full-size.component';
|
|
|
|
|
import {ChatBoxComponent} from '@pages/altitude/chat/components/chat/chat-box.component';
|
|
|
|
|
import {ServerListComponent} from '@pages/altitude/chat/components/server-list/server-list.component';
|
|
|
|
|
import {ChatInfoComponent} from '@pages/altitude/chat/components/chat-info/chat-info.component';
|
2026-07-18 22:22:54 +00:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-chat',
|
2026-07-18 22:59:04 +00:00
|
|
|
imports: [
|
|
|
|
|
HeaderComponent,
|
2026-07-19 15:12:03 +00:00
|
|
|
FullSizeComponent,
|
|
|
|
|
ChatBoxComponent,
|
|
|
|
|
ServerListComponent,
|
|
|
|
|
ChatInfoComponent
|
2026-07-18 22:59:04 +00:00
|
|
|
],
|
2026-07-18 22:22:54 +00:00
|
|
|
templateUrl: './chat.component.html',
|
2026-07-18 22:59:04 +00:00
|
|
|
styleUrl: './chat.component.scss',
|
|
|
|
|
providers: [MiniMessageInteractionService]
|
2026-07-18 22:22:54 +00:00
|
|
|
})
|
|
|
|
|
export class ChatComponent implements OnInit, OnDestroy {
|
|
|
|
|
private sub?: Subscription;
|
2026-07-18 22:59:04 +00:00
|
|
|
private readonly chatService: ChatService = inject(ChatService)
|
|
|
|
|
protected readonly messages = this.chatService.messages;
|
2026-07-19 15:12:03 +00:00
|
|
|
protected readonly servers = this.chatService.servers;
|
|
|
|
|
protected readonly selectedServer = this.chatService.selectedServer;
|
2026-07-18 22:22:54 +00:00
|
|
|
|
2026-07-18 22:59:04 +00:00
|
|
|
constructor(private interaction: MiniMessageInteractionService) {
|
|
|
|
|
interaction.clicks$.subscribe(({action, value}) => {
|
|
|
|
|
if (action === 'run_command') {
|
|
|
|
|
alert(value);
|
2026-07-18 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-19 15:12:03 +00:00
|
|
|
public onSelectedServerChange(server: string) {
|
|
|
|
|
this.chatService.selectServer(server);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-18 22:59:04 +00:00
|
|
|
ngOnInit(): void {
|
|
|
|
|
this.chatService.connect();
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-18 22:22:54 +00:00
|
|
|
ngOnDestroy(): void {
|
|
|
|
|
this.sub?.unsubscribe();
|
2026-07-18 22:59:04 +00:00
|
|
|
this.chatService.disconnect(); // triggers onCompletion server-side, cleans up the emitter
|
2026-07-18 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
}
|