diff --git a/gramjs/Utils.ts b/gramjs/Utils.ts index ad72fcef..1e6b3bd3 100644 --- a/gramjs/Utils.ts +++ b/gramjs/Utils.ts @@ -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; } } diff --git a/gramjs/tl/custom/file.ts b/gramjs/tl/custom/file.ts index c51a6955..d8790fb3 100644 --- a/gramjs/tl/custom/file.ts +++ b/gramjs/tl/custom/file.ts @@ -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; }