Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix file size getter #659

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading