@@ -65,3 +65,50 @@ index 37a2552..850825f 100644
6565 @if (documentsButton) {
6666 <button aria-label="Archive the current document" mat-icon-button color="primary"
6767 (click)="documentsEmiter(idea);">
68+ diff --git a/web/src/app/card-idea/card-idea.component.ts b/web/src/app/card-idea/card-idea.component.ts
69+ index 1d60a6f..1c45524 100644
70+ --- a/web/src/app/card-idea/card-idea.component.ts
71+ +++ b/web/src/app/card-idea/card-idea.component.ts
72+ @@ -32,6 +32,7 @@ import { MatSnackBarModule } from '@angular/material/snack-bar';
73+ import { MatTooltipModule } from '@angular/material/tooltip';
74+
75+ // Third-party Libraries
76+ +import { io, Socket as SocketIoClientSocket } from 'socket.io-client';
77+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
78+
79+ // Application-specific Services and Models
80+ @@ -156,6 +157,7 @@ export class CardIdeaComponent implements OnInit, OnChanges, OnDestroy {
81+ _addIdeaButtonActive = signal(false);
82+
83+ /** Private instance of the Socket.IO client for real-time communication (e.g., sharing). */
84+ + private socket: SocketIoClientSocket;
85+ private destroyRef = inject(DestroyRef);
86+
87+ /**
88+ @@ -172,6 +174,9 @@ export class CardIdeaComponent implements OnInit, OnChanges, OnDestroy {
89+ private genkitService: GenkitService,
90+ private languageService: LanguageService,
91+ ) {
92+ + this.socket = io(environment.socketAddr, {
93+ + transports: ['websocket']
94+ + });
95+ }
96+
97+ /**
98+ @@ -273,6 +278,7 @@ export class CardIdeaComponent implements OnInit, OnChanges, OnDestroy {
99+
100+ if (cardIdea && cardIdea.text) {
101+ const payload = { text: cardIdea.text };
102+ + this.socket.emit('idea', payload);
103+ } else {
104+ console.warn('No text to share.');
105+ }
106+ @@ -542,5 +548,8 @@ export class CardIdeaComponent implements OnInit, OnChanges, OnDestroy {
107+ * Disconnects the Socket.IO client to prevent memory leaks and lingering connections.
108+ */
109+ ngOnDestroy(): void {
110+ + if (this.socket) {
111+ + this.socket.disconnect();
112+ + }
113+ }
114+ }
0 commit comments