Skip to content

Commit fb01204

Browse files
committed
Show progressbar on sign-in page with GitHub backend
1 parent 4bce37c commit fb01204

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/lib/services/backends/github.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { initServerSideAuth } from '$lib/services/backends/shared/auth';
88
import { createCommitMessage } from '$lib/services/backends/shared/commits';
99
import { fetchAndParseFiles } from '$lib/services/backends/shared/data';
1010
import { siteConfig } from '$lib/services/config';
11+
import { dataLoadedProgress } from '$lib/services/contents';
1112
import { user } from '$lib/services/user';
1213
import { sendRequest } from '$lib/services/utils/networking';
1314

@@ -393,6 +394,13 @@ const fetchFileContents = async (fetchingFiles) => {
393394
`;
394395
};
395396

397+
dataLoadedProgress.set(0);
398+
399+
// Show a fake progressbar because the request waiting time is long
400+
const dataLoadedProgressInterval = window.setInterval(() => {
401+
dataLoadedProgress.update((progress = 0) => progress + 1);
402+
}, fetchingFileList.length / 10);
403+
396404
for (let i = 0; i < fetchingFileList.length; i += chunkSize) {
397405
chunks.push(fetchingFileList.slice(i, i + chunkSize));
398406
}
@@ -411,6 +419,9 @@ const fetchFileContents = async (fetchingFiles) => {
411419
}),
412420
);
413421

422+
window.clearInterval(dataLoadedProgressInterval);
423+
dataLoadedProgress.set(undefined);
424+
414425
return Object.fromEntries(
415426
fetchingFiles.map(({ path, sha, size }, index) => {
416427
const {

0 commit comments

Comments
 (0)