aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Network.ts9
-rw-r--r--src/client/views/nodes/LoadingBox.tsx16
2 files changed, 24 insertions, 1 deletions
diff --git a/src/client/Network.ts b/src/client/Network.ts
index 996eb35d8..19eff3b3b 100644
--- a/src/client/Network.ts
+++ b/src/client/Network.ts
@@ -62,4 +62,13 @@ export namespace Networking {
const response = await fetch('/uploadYoutubeVideo', parameters);
return response.json();
}
+ export async function QueryYoutubeProgress(videoId: string): Promise<{ progress: string }> {
+ const parameters = {
+ method: 'POST',
+ body: JSON.stringify({ videoId }),
+ json: true,
+ };
+ const response = await fetch('/queryYoutubeProgress', parameters);
+ return response.json();
+ }
}
diff --git a/src/client/views/nodes/LoadingBox.tsx b/src/client/views/nodes/LoadingBox.tsx
index 53390328f..8c5255f80 100644
--- a/src/client/views/nodes/LoadingBox.tsx
+++ b/src/client/views/nodes/LoadingBox.tsx
@@ -1,8 +1,10 @@
+import { action, observable, runInAction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import ReactLoading from 'react-loading';
import { Doc } from '../../../fields/Doc';
import { StrCast } from '../../../fields/Types';
+import { Networking } from '../../Network';
import { ViewBoxAnnotatableComponent } from '../DocComponent';
import { FieldView, FieldViewProps } from './FieldView';
import './LoadingBox.scss';
@@ -34,17 +36,29 @@ export class LoadingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
return FieldView.LayoutString(LoadingBox, fieldKey);
}
+ _timer: any;
+ @observable progress = '';
componentDidMount() {
if (!Doc.CurrentlyLoading?.includes(this.rootDoc)) {
this.rootDoc.loadingError = 'Upload interrupted, please try again';
+ } else {
+ const updateFunc = async () => {
+ const result = await Networking.QueryYoutubeProgress(StrCast(this.rootDoc.title));
+ runInAction(() => (this.progress = result.progress));
+ this._timer = setTimeout(updateFunc, 1000);
+ };
+ this._timer = setTimeout(updateFunc, 1000);
}
}
+ componentWillUnmount() {
+ clearTimeout(this._timer);
+ }
render() {
return (
<div className="loadingBoxContainer" style={{ background: !this.rootDoc.loadingError ? '' : 'red' }}>
<div className="textContainer">
- <p className="headerText">{StrCast(this.rootDoc.loadingError, 'Loading (can take several minutes):')}</p>
+ <p className="headerText">{StrCast(this.rootDoc.loadingError, 'Loading ' + (this.progress.replace('[download]', '') || '(can take several minutes)'))}</p>
<span className="text">{StrCast(this.rootDoc.title)}</span>
{this.rootDoc.loadingError ? null : <ReactLoading type={'spinningBubbles'} color={'blue'} height={100} width={100} />}
</div>