Skip to content

Commit 42582b8

Browse files
feat(annotaions): refactor after code review
1 parent 7fb65e4 commit 42582b8

File tree

7 files changed

+19
-16
lines changed

7 files changed

+19
-16
lines changed

apps/spa/src/app/components/chat/chat-annotation/chat-annotation.component.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ describe('ChatAnnotationComponent', () => {
88

99
beforeEach(async () => {
1010
await TestBed.configureTestingModule({
11-
imports: [
12-
ChatAnnotationComponent,
13-
HttpClientTestingModule,
14-
],
11+
imports: [ChatAnnotationComponent, HttpClientTestingModule],
1512
}).compileComponents();
1613

1714
fixture = TestBed.createComponent(ChatAnnotationComponent);

apps/spa/src/app/components/chat/chat-annotations/chat-annotations.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
@if (message && message.type === 'text' && message.text.annotations.length) {
22
<div class="title">Annotations:</div>
33
<div class="content">
4-
@for (annotation of message.text.annotations; track annotation.text) {
4+
@for (
5+
annotation of message.text.annotations;
6+
track annotation.text + $index
7+
) {
58
<ai-chat-annotation [annotation]="annotation" [index]="$index + 1">
69
[{{ $index + 1 }}]
710
</ai-chat-annotation>

apps/spa/src/app/components/chat/chat-message/chat-message.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}
55

66
<div class="chat-message">
7-
@for (msg of message.content; track msg) {
7+
@for (msg of message.content; track $index) {
88
@if (msg.type === 'text') {
99
<span markdown [data]="msg | annotation"></span>
1010
}

apps/spa/src/app/components/chat/chat-messages/chat-messages.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="messages">
2-
@for (message of initialMessages.concat(messages); track message) {
2+
@for (message of initialMessages.concat(messages); track message.id) {
33
<span #item>
44
<ai-chat-message [message]="message"></ai-chat-message>
55
</span>
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@for (tip of tips; track tip) {
2-
<ai-chat-tip (click)="tipSelected$.emit(tip)">
3-
{{ tip }}
4-
</ai-chat-tip>
1+
@for (tip of tips; track $index) {
2+
<ai-chat-tip (click)="tipSelected$.emit(tip)">
3+
{{ tip }}
4+
</ai-chat-tip>
55
}

apps/spa/src/app/components/controls/files/files.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ export class FilesService {
66
files$ = new BehaviorSubject<File[]>([]);
77

88
add(files: FileList) {
9+
const convertedFiles = Object.keys(files).map(
10+
key => files[key as unknown as number],
11+
);
912
const updatedFiles = [
1013
...this.files$.value,
11-
...Object.keys(files).map(key => files[key as unknown as number]),
14+
...convertedFiles,
1215
];
1316

1417
this.files$.next(updatedFiles);

apps/spa/src/app/components/controls/message-content/message-content.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ export class MessageContentService {
1010
constructor(private readonly chatClientService: ChatClientService) {}
1111

1212
add(files: FileList) {
13-
const updatedFiles = [
14-
...this.data$.value,
15-
...Object.keys(files).map(key => files[key as unknown as number]),
16-
];
13+
const convertedFiles = Object.keys(files).map(
14+
key => files[key as unknown as number],
15+
);
16+
const updatedFiles = [...this.data$.value, ...convertedFiles];
1717
this.data$.next(updatedFiles);
1818
}
1919

0 commit comments

Comments
 (0)