aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/LoadingBox.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-12-21 14:55:48 -0500
committerbobzel <zzzman@gmail.com>2023-12-21 14:55:48 -0500
commit1caba64ee0f32ee8af79263cd4ef2a8bc5d5146e (patch)
tree0fa0e957d1f342fdc6ed4a4b43f5dddfddb1298a /src/client/views/nodes/LoadingBox.tsx
parent02eb7da95df283606d4275a22d9451cef371c3b5 (diff)
parent2691b951d96f2ce7652acbea9e340b61737b3b57 (diff)
Merge branch 'moreUpgrading' into dataViz-annotations
Diffstat (limited to 'src/client/views/nodes/LoadingBox.tsx')
-rw-r--r--src/client/views/nodes/LoadingBox.tsx31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/client/views/nodes/LoadingBox.tsx b/src/client/views/nodes/LoadingBox.tsx
index 4bb0f14d2..27d73a585 100644
--- a/src/client/views/nodes/LoadingBox.tsx
+++ b/src/client/views/nodes/LoadingBox.tsx
@@ -6,6 +6,7 @@ import { Doc } from '../../../fields/Doc';
import { Id } from '../../../fields/FieldSymbols';
import { StrCast } from '../../../fields/Types';
import { Networking } from '../../Network';
+import { DocumentManager } from '../../util/DocumentManager';
import { ViewBoxAnnotatableComponent } from '../DocComponent';
import { FieldView, FieldViewProps } from './FieldView';
import './LoadingBox.scss';
@@ -36,49 +37,47 @@ export class LoadingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
public static LayoutString(fieldKey: string) {
return FieldView.LayoutString(LoadingBox, fieldKey);
}
- @observable public static CurrentlyLoading: Doc[] = []; // this assignment doesn't work. the actual assignment happens in DocumentManager's constructor
// removes from currently loading display
- @action
public static removeCurrentlyLoading(doc: Doc) {
- if (LoadingBox.CurrentlyLoading) {
- const index = LoadingBox.CurrentlyLoading.indexOf(doc);
- index !== -1 && LoadingBox.CurrentlyLoading.splice(index, 1);
+ if (DocumentManager.Instance.CurrentlyLoading) {
+ const index = DocumentManager.Instance.CurrentlyLoading.indexOf(doc);
+ runInAction(() => index !== -1 && DocumentManager.Instance.CurrentlyLoading.splice(index, 1));
}
}
// adds doc to currently loading display
- @action
public static addCurrentlyLoading(doc: Doc) {
- if (LoadingBox.CurrentlyLoading.indexOf(doc) === -1) {
- LoadingBox.CurrentlyLoading.push(doc);
+ if (DocumentManager.Instance.CurrentlyLoading.indexOf(doc) === -1) {
+ runInAction(() => DocumentManager.Instance.CurrentlyLoading.push(doc));
}
}
_timer: any;
@observable progress = '';
componentDidMount() {
- if (!LoadingBox.CurrentlyLoading?.includes(this.rootDoc)) {
- this.rootDoc.loadingError = 'Upload interrupted, please try again';
+ if (!DocumentManager.Instance.CurrentlyLoading?.includes(this.Document)) {
+ this.Document.loadingError = 'Upload interrupted, please try again';
} else {
const updateFunc = async () => {
- const result = await Networking.QueryYoutubeProgress(StrCast(this.rootDoc[Id])); // We use the guid of the overwriteDoc to track file uploads.
+ const result = await Networking.QueryYoutubeProgress(StrCast(this.Document[Id])); // We use the guid of the overwriteDoc to track file uploads.
runInAction(() => (this.progress = result.progress));
- !this.rootDoc.loadingError && (this._timer = setTimeout(updateFunc, 1000));
+ !this.Document.loadingError && this._timer && (this._timer = setTimeout(updateFunc, 1000));
};
this._timer = setTimeout(updateFunc, 1000);
}
}
componentWillUnmount() {
clearTimeout(this._timer);
+ this._timer = undefined;
}
render() {
return (
- <div className="loadingBoxContainer" style={{ background: !this.rootDoc.loadingError ? '' : 'red' }}>
+ <div className="loadingBoxContainer" style={{ background: !this.Document.loadingError ? '' : 'red' }}>
<div className="loadingBox-textContainer">
- <span className="loadingBox-title">{StrCast(this.rootDoc.title)}</span>
- <p className="loadingBox-headerText">{StrCast(this.rootDoc.loadingError, 'Loading ' + (this.progress.replace('[download]', '') || '(can take several minutes)'))}</p>
- {this.rootDoc.loadingError ? null : (
+ <span className="loadingBox-title">{StrCast(this.Document.title)}</span>
+ <p className="loadingBox-headerText">{StrCast(this.Document.loadingError, 'Loading ' + (this.progress.replace('[download]', '') || '(can take several minutes)'))}</p>
+ {this.Document.loadingError ? null : (
<div className="loadingBox-spinner">
<ReactLoading type="spinningBubbles" color="blue" height={100} width={100} />
</div>