ciyidogan commited on
Commit
1bffd96
·
verified ·
1 Parent(s): 3d47b64

Update flare-ui/src/app/components/chat/realtime-chat.component.ts

Browse files
flare-ui/src/app/components/chat/realtime-chat.component.ts CHANGED
@@ -106,6 +106,13 @@ export class RealtimeChatComponent implements OnInit, OnDestroy, AfterViewChecke
106
  console.log('📊 Conversation state:', state);
107
  this.currentState = state;
108
  this.updateRecordingState(state);
 
 
 
 
 
 
 
109
  });
110
 
111
  // Subscribe to transcription
@@ -118,6 +125,14 @@ export class RealtimeChatComponent implements OnInit, OnDestroy, AfterViewChecke
118
  this.currentTranscription = text;
119
  });
120
 
 
 
 
 
 
 
 
 
121
  // Load initial messages from session if available
122
  const initialMessages = this.conversationManager.getMessages();
123
  console.log('📋 Initial messages:', initialMessages.length);
@@ -125,8 +140,8 @@ export class RealtimeChatComponent implements OnInit, OnDestroy, AfterViewChecke
125
  this.messages = initialMessages;
126
  this.shouldScrollToBottom = true;
127
  }
128
- }
129
-
130
  ngAfterViewChecked(): void {
131
  if (this.shouldScrollToBottom) {
132
  this.scrollToBottom();
@@ -166,6 +181,8 @@ export class RealtimeChatComponent implements OnInit, OnDestroy, AfterViewChecke
166
 
167
  await this.conversationManager.startConversation(this.sessionId!);
168
  this.isConversationActive = true;
 
 
169
  this.startVisualization();
170
 
171
  this.snackBar.open('Konuşma başlatıldı', 'Close', {
@@ -286,7 +303,16 @@ export class RealtimeChatComponent implements OnInit, OnDestroy, AfterViewChecke
286
  }
287
 
288
  private updateRecordingState(state: ConversationState): void {
 
289
  this.isRecording = state === 'listening';
 
 
 
 
 
 
 
 
290
  }
291
 
292
  private scrollToBottom(): void {
 
106
  console.log('📊 Conversation state:', state);
107
  this.currentState = state;
108
  this.updateRecordingState(state);
109
+
110
+ // Visualization'ı state'e göre güncelle
111
+ if (state === 'listening') {
112
+ this.isRecording = true;
113
+ } else {
114
+ this.isRecording = false;
115
+ }
116
  });
117
 
118
  // Subscribe to transcription
 
125
  this.currentTranscription = text;
126
  });
127
 
128
+ // Subscribe to errors
129
+ this.conversationManager.error$.pipe(
130
+ takeUntil(this.destroyed$)
131
+ ).subscribe(error => {
132
+ console.error('Conversation error:', error);
133
+ this.error = error.message;
134
+ });
135
+
136
  // Load initial messages from session if available
137
  const initialMessages = this.conversationManager.getMessages();
138
  console.log('📋 Initial messages:', initialMessages.length);
 
140
  this.messages = initialMessages;
141
  this.shouldScrollToBottom = true;
142
  }
143
+ }
144
+
145
  ngAfterViewChecked(): void {
146
  if (this.shouldScrollToBottom) {
147
  this.scrollToBottom();
 
181
 
182
  await this.conversationManager.startConversation(this.sessionId!);
183
  this.isConversationActive = true;
184
+
185
+ // Visualization'ı başlat
186
  this.startVisualization();
187
 
188
  this.snackBar.open('Konuşma başlatıldı', 'Close', {
 
303
  }
304
 
305
  private updateRecordingState(state: ConversationState): void {
306
+ // State'e göre recording durumunu güncelle
307
  this.isRecording = state === 'listening';
308
+
309
+ // Visualizer'ı güncelle
310
+ if (this.isRecording && this.isConversationActive) {
311
+ // Eğer visualizer çalışmıyorsa başlat
312
+ if (!this.animationId) {
313
+ this.startVisualization();
314
+ }
315
+ }
316
  }
317
 
318
  private scrollToBottom(): void {