Pārlūkot izejas kodu

fix: download progress callback (#709)

* fix(type): progress callback defination

* fix: downloaded progress
liyu 9 mēneši atpakaļ
vecāks
revīzija
7db1921823
2 mainītis faili ar 3 papildinājumiem un 3 dzēšanām
  1. 1 1
      gramjs/client/downloads.ts
  2. 2 2
      gramjs/define.d.ts

+ 1 - 1
gramjs/client/downloads.ts

@@ -430,13 +430,13 @@ export async function downloadFileV2(
             msgData: msgData,
         })) {
             await writer.write(chunk);
+            downloaded = downloaded.add(chunk.length);
             if (progressCallback) {
                 await progressCallback(
                     downloaded,
                     bigInt(fileSize || bigInt.zero)
                 );
             }
-            downloaded = downloaded.add(chunk.length);
         }
         return returnWriterValue(writer);
     } finally {

+ 2 - 2
gramjs/define.d.ts

@@ -64,8 +64,8 @@ type OutFile =
     | WriteStream
     | { write: Function; close?: Function };
 type ProgressCallback = (
-    total: bigInt.BigInteger,
-    downloaded: bigInt.BigInteger
+    downloaded: bigInt.BigInteger,
+    total: bigInt.BigInteger
 ) => void;
 type ButtonLike = Api.TypeKeyboardButton | Button;