From 0cf5f0ff6a251827f9fb8e563db8091d7ade536b Mon Sep 17 00:00:00 2001 From: keef3ar <35760257+keef3ar@users.noreply.github.com> Date: Wed, 3 Apr 2024 12:25:03 +0400 Subject: [PATCH] fix file size getter (#659) --- gramjs/Utils.ts | 5 ++++- gramjs/tl/custom/file.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) 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; }