Update loading
This commit is contained in:
@@ -37,18 +37,17 @@
|
|||||||
function xhrDownloadFileId(fileId: string) {
|
function xhrDownloadFileId(fileId: string) {
|
||||||
return new Promise<Blob>((resolve, reject) => {
|
return new Promise<Blob>((resolve, reject) => {
|
||||||
const { access_token } = gapi.auth.getToken();
|
const { access_token } = gapi.auth.getToken();
|
||||||
|
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
|
completed = 0;
|
||||||
|
totalSize = 0;
|
||||||
|
|
||||||
xhr.open('GET', `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`);
|
xhr.open('GET', `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`);
|
||||||
xhr.setRequestHeader('Authorization', `Bearer ${access_token}`);
|
xhr.setRequestHeader('Authorization', `Bearer ${access_token}`);
|
||||||
xhr.responseType = 'blob';
|
xhr.responseType = 'blob';
|
||||||
|
|
||||||
xhr.onloadstart = () => {
|
|
||||||
completed = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
xhr.onprogress = ({ loaded, total }) => {
|
xhr.onprogress = ({ loaded, total }) => {
|
||||||
|
loadingMessage = '';
|
||||||
completed = loaded;
|
completed = loaded;
|
||||||
totalSize = total;
|
totalSize = total;
|
||||||
};
|
};
|
||||||
@@ -292,9 +291,9 @@
|
|||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class="p-2 h-[90svh]">
|
<div class="p-2 h-[90svh]">
|
||||||
{#if loadingMessage}
|
{#if loadingMessage || completed > 0}
|
||||||
<Loader>
|
<Loader>
|
||||||
{#if completed > 0 && completed !== totalSize}
|
{#if completed > 0}
|
||||||
<P>{formatBytes(completed)} / {formatBytes(totalSize)}</P>
|
<P>{formatBytes(completed)} / {formatBytes(totalSize)}</P>
|
||||||
<Progressbar {progress} />
|
<Progressbar {progress} />
|
||||||
{:else}
|
{:else}
|
||||||
|
|||||||
Reference in New Issue
Block a user