Skip to content

Commit f5ea990

Browse files
committed
if uploaded >= video total, assume upload is complete
1 parent 2d0ac87 commit f5ea990

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

apps/web/app/s/[videoId]/_components/ProgressCircle.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,22 @@ export function useUploadProgress(
5151

5252
const lastUpdated = new Date(query.data.updatedAt);
5353

54-
return Date.now() - lastUpdated.getTime() > 5 * MINUTE
55-
? {
56-
status: "failed",
57-
lastUpdated,
58-
}
59-
: {
60-
status: "uploading",
61-
lastUpdated,
62-
progress:
63-
// `0/0` for progress is `NaN`
64-
query.data.total === 0
65-
? 0
66-
: (query.data.uploaded / query.data.total) * 100,
67-
};
54+
return query.data.uploaded >= query.data.total
55+
? null
56+
: Date.now() - lastUpdated.getTime() > 5 * MINUTE
57+
? {
58+
status: "failed",
59+
lastUpdated,
60+
}
61+
: {
62+
status: "uploading",
63+
lastUpdated,
64+
progress:
65+
// `0/0` for progress is `NaN`
66+
query.data.total === 0
67+
? 0
68+
: (query.data.uploaded / query.data.total) * 100,
69+
};
6870
}
6971

7072
const ProgressCircle = ({

0 commit comments

Comments
 (0)