Skip to content

Commit 65a93b1

Browse files
authored
Merge pull request #210 from GetStream/fix-file-size-handling
feat: Add support for stream-chat 5.6
2 parents 71c01b2 + 3181b85 commit 65a93b1

File tree

7 files changed

+28
-13
lines changed

7 files changed

+28
-13
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"emoji-regex": "^10.0.0",
9595
"pretty-bytes": "^5.6.0",
9696
"rxjs": "~6.6.0",
97-
"stream-chat": "^5.0.0",
97+
"stream-chat": "^5.6.0",
9898
"ts-node": "^10.2.1",
9999
"tslib": "^2.3.0",
100100
"uuidv4": "^6.2.12",

projects/stream-chat-angular/src/lib/attachment-list/attachment-list.component.spec.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,18 @@ describe('AttachmentListComponent', () => {
376376
];
377377
component.ngOnChanges();
378378
fixture.detectChanges();
379-
const preview = queryAttachments()[0];
380-
const fileSize = preview.querySelector('[data-testclass="size"]');
379+
let preview = queryAttachments()[0];
380+
let fileSize = preview.querySelector('[data-testclass="size"]');
381+
382+
expect(fileSize?.textContent).toContain('3.27 MB');
383+
384+
component.attachments = [
385+
{ type: 'file', title, asset_url, file_size: '3272969' },
386+
];
387+
component.ngOnChanges();
388+
fixture.detectChanges();
389+
preview = queryAttachments()[0];
390+
fileSize = preview.querySelector('[data-testclass="size"]');
381391

382392
expect(fileSize?.textContent).toContain('3.27 MB');
383393
});

projects/stream-chat-angular/src/lib/attachment-list/attachment-list.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class AttachmentListComponent implements OnChanges {
6969
}
7070

7171
getFileSize(attachment: Attachment<DefaultAttachmentType>) {
72-
return prettybytes(attachment.file_size!);
72+
return prettybytes(Number(attachment.file_size!));
7373
}
7474

7575
trimUrl(url?: string | null) {

projects/stream-chat-angular/src/lib/channel.service.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,9 @@ describe('ChannelService', () => {
11201120
expect(latestMessage.readBy.length).toBe(0);
11211121

11221122
const user = { id: 'jack', name: 'Jack' } as UserResponse;
1123-
channel.state.read = { [user.id]: { last_read: new Date(), user } };
1123+
channel.state.read = {
1124+
[user.id]: { last_read: new Date(), user, unread_messages: 0 },
1125+
};
11241126
(channel as MockChannel).handleEvent('message.read', {
11251127
user,
11261128
});

projects/stream-chat-angular/src/lib/read-by.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,28 @@ describe('getReadBy', () => {
2020
id: 'id1',
2121
name: 'John',
2222
},
23+
unread_messages: 2,
2324
},
2425
sender: {
2526
last_read: new Date('2021-09-14T13:09:01.004112Z'),
2627
user: sender,
28+
unread_messages: 2,
2729
},
2830
id2: {
2931
last_read: new Date('2021-09-14T13:05:30.004112Z'),
3032
user: {
3133
id: 'id2',
3234
name: 'Alice',
3335
},
36+
unread_messages: 2,
3437
},
3538
id3: {
3639
last_read: new Date('2021-09-14T13:08:30.004112Z'),
3740
user: {
3841
id: 'id3',
3942
name: 'Bob',
4043
},
44+
unread_messages: 2,
4145
},
4246
};
4347
const result = getReadBy(message, channel);

projects/stream-chat-angular/src/lib/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export type CustomTrigger = {
1919

2020
export type DefaultAttachmentType = UnknownType & {
2121
asset_url?: string;
22-
file_size?: number;
2322
id?: string;
2423
images?: Array<{
2524
image_url?: string;

0 commit comments

Comments
 (0)