Skip to content

Commit

Permalink
fix(Load manager): fixed the downloaded bytes onProgress call
Browse files Browse the repository at this point in the history
  • Loading branch information
divya-sea committed Aug 14, 2023
1 parent 21bcf3b commit acfded8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe('useProgress', () => {
// Assert
expect(setMock).toBeCalledWith({
active: true,
downloaded: 25,
item,
loaded,
total,
Expand All @@ -86,6 +87,7 @@ describe('useProgress', () => {
const item = 'test-url';
const loaded = 100;
const total = 100;

const setMock = jest.fn();
useProgressImpl(setMock);

Expand All @@ -98,6 +100,7 @@ describe('useProgress', () => {
item,
loaded,
total,
downloaded: 0,
progress: 100,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Data = {
downloadProgress: number;
};
let saveLastTotalLoaded = 0;
const downloaded = 0;

export const useProgressImpl = (set) => {
[DefaultLoadingManager, ...tmLoadingManagers].forEach((manager) => {
Expand All @@ -40,6 +41,7 @@ export const useProgressImpl = (set) => {
active: true,
item,
loaded,
downloaded: downloaded + (loaded - saveLastTotalLoaded),
total,
progress: ((loaded - saveLastTotalLoaded) / (total - saveLastTotalLoaded)) * 100 || 100,
});
Expand Down

0 comments on commit acfded8

Please sign in to comment.