Skip to content

Commit

Permalink
fix file size getter (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
keef3ar authored Apr 3, 2024
1 parent e61fbcb commit 0cf5f0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion gramjs/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ export function _photoSizeByteCount(size: Api.TypePhotoSize) {
return size.bytes.length;
} else if (size instanceof Api.PhotoSizeEmpty) {
return 0;
} else {
} else if (size instanceof Api.PhotoSizeProgressive) {
return size.sizes[size.sizes.length -1];
}
else {
return undefined;
}
}
Expand Down
2 changes: 1 addition & 1 deletion gramjs/tl/custom/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class File {

get size() {
if (this.media instanceof Api.Photo) {
return _photoSizeByteCount(this.media.sizes[-1]);
return _photoSizeByteCount(this.media.sizes[this.media.sizes.length -1]);
} else if (this.media instanceof Api.Document) {
return this.media.size;
}
Expand Down

0 comments on commit 0cf5f0f

Please sign in to comment.