Skip to content
This repository was archived by the owner on Aug 29, 2022. It is now read-only.

Commit c8743d8

Browse files
committed
Conversations Issue Fixed
1 parent a24010a commit c8743d8

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

ui-trainer/src/app/common/services/apis.service.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,11 @@ export class ApiService {
143143
);
144144
}
145145

146-
forceConversationsCacheReload(type: string) {
147-
if (type === 'reset') {
146+
forceConversationsCacheReload() {
148147
// Calling next will complete the current cache instance
149148
this.reloadConversations$.next();
150149
// Setting the cache to null will create a new cache the
151150
this.conversationsCache$ = null;
152-
} else if (type === 'finish') {
153-
// Calling next will complete the current cache instance
154-
this.reloadConversations$.next();
155-
}
156151
}
157152
// Conversations API End
158153

ui-trainer/src/app/conversations/conversations.component.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class ConversationsComponent implements OnInit, OnDestroy {
2323
conversationsDataSource: any;
2424
conversations_json: Array<object>;
2525
conversations_json_backup: Array<object>;
26-
filterConversationText: string;
26+
filterConversationText = '';
2727

2828
@ViewChild(MatPaginator) paginator: MatPaginator;
2929

@@ -38,7 +38,8 @@ export class ConversationsComponent implements OnInit, OnDestroy {
3838
getConversations() {
3939
this.apiService.requestConversations().subscribe(conversations => {
4040
if (conversations) {
41-
this.conversations_json = this.conversations_json_backup = conversations;
41+
this.conversations_json = conversations.slice();
42+
this.conversations_json_backup = JSON.parse(JSON.stringify(this.conversations_json));
4243
this.conversationsDataSource = new MatTableDataSource(this.conversations_json);
4344
this.conversationsDataSource.paginator = this.paginator;
4445
this.applyConversationsFilter(this.filterConversationText);
@@ -72,7 +73,7 @@ export class ConversationsComponent implements OnInit, OnDestroy {
7273

7374
openConversationChat(conversation_id: string) {
7475
// tslint:disable-next-line: max-line-length
75-
this.sharedDataService.setSharedData('conversation_json', this.conversations_json.filter(conversations => conversations['sender_id'] === conversation_id), constant.MODULE_COMMON);
76+
this.sharedDataService.setSharedData('conversation_json', this.conversations_json_backup.filter(conversations => conversations['sender_id'] === conversation_id), constant.MODULE_COMMON);
7677
this._router.navigate(['/home/conversations/' + conversation_id]);
7778
}
7879

@@ -81,7 +82,7 @@ export class ConversationsComponent implements OnInit, OnDestroy {
8182
}
8283

8384
ngOnDestroy(): void {
84-
this.apiService.forceConversationsCacheReload('finish');
85+
this.apiService.forceConversationsCacheReload();
8586
}
8687

8788
}

0 commit comments

Comments
 (0)