Skip to content

Commit

Permalink
persistant chat window on courses
Browse files Browse the repository at this point in the history
  • Loading branch information
RheuX committed Jan 27, 2025
1 parent d95f525 commit 95167f2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/app/chat/chat-window/chat-window.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ChatWindowComponent implements OnInit, OnDestroy, AfterViewInit {
disabled = false;
clearChat = true;
provider: AIProvider;
conversations: any[] = [];
fallbackConversation: any[] = [];
selectedConversationId: any;
promptForm: FormGroup;
data: ConversationForm = {
Expand All @@ -36,6 +36,7 @@ export class ChatWindowComponent implements OnInit, OnDestroy, AfterViewInit {
};
providers: AIProvider[] = [];
@Input() context: any;
@Input() conversations: any[] | null = null;
@ViewChild('chatInput') chatInput: ElementRef;
@ViewChild('chat') chatContainer: ElementRef;

Expand All @@ -48,6 +49,9 @@ export class ChatWindowComponent implements OnInit, OnDestroy, AfterViewInit {
) {}

ngOnInit() {
if (this.conversations === null) {
this.conversations = this.fallbackConversation;
}
this.createForm();
this.subscribeToNewChatSelected();
this.subscribeToSelectedConversation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ <h3 class="margin-lr-3 ellipsis-title"><ng-container i18n>Step</ng-container> {{
</div>
</mat-toolbar>
<div class="view-container view-full-height" [ngClass]="{'grid-view': showChat, 'flex-view': !isGridView && !showChat}" *ngIf="stepDetail?.description || resource?._attachments; else emptyRecord">
<planet-chat-window *ngIf="showChat" [context]="{type: 'coursestep', data: localizedStepInfo, resource: { id: resource?._id, attachments: resource?._attachments } }"></planet-chat-window>
<planet-chat-window *ngIf="showChat" [context]="{type: 'coursestep', data: localizedStepInfo, resource: { id: resource?._id, attachments: resource?._attachments } }" [conversations]="conversations"></planet-chat-window>
<ng-container *ngIf="showChat; else stepViewContent">
<div class="flex-view">
<ng-container *ngTemplateOutlet="stepViewContent"></ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class CoursesStepViewComponent implements OnInit, OnDestroy {
onDestroy$ = new Subject<void>();
stepNum = 0;
stepDetail: any = { stepTitle: '', description: '', resources: [] };
conversations: any[] = [];
courseId: string;
maxStep = 1;
resourceUrl = '';
Expand Down Expand Up @@ -139,6 +140,7 @@ export class CoursesStepViewComponent implements OnInit, OnDestroy {
changeStep(direction) {
this.isLoading = true;
this.router.navigate([ '../' + (this.stepNum + direction) ], { relativeTo: this.route });
this.conversations = [];
this.resetCourseStep();
this.countActivity = true;
}
Expand Down

0 comments on commit 95167f2

Please sign in to comment.