Skip to content

Commit

Permalink
fix: download progress callback (#709)
Browse files Browse the repository at this point in the history
* fix(type): progress callback defination

* fix: downloaded progress
  • Loading branch information
yunyu950908 authored Aug 11, 2024
1 parent 1094d12 commit 7db1921
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gramjs/client/downloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions gramjs/define.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 7db1921

Please sign in to comment.