aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionSubView.tsx
diff options
context:
space:
mode:
authorNaafiyan Ahmed <naafiyan@gmail.com>2022-08-16 16:43:01 -0400
committerNaafiyan Ahmed <naafiyan@gmail.com>2022-08-16 16:43:01 -0400
commitbb2b38b0e47eaf8e64554d101b605bf35a178239 (patch)
treef8b020f757a57d0ced447d3c4e6277c4c0f0175f /src/client/views/collections/CollectionSubView.tsx
parent820d40eea4eeb5977889e0ef6c35f9092df44b4b (diff)
updated placeholder
Diffstat (limited to 'src/client/views/collections/CollectionSubView.tsx')
-rw-r--r--src/client/views/collections/CollectionSubView.tsx70
1 files changed, 23 insertions, 47 deletions
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 79f629072..1ff4f5ab8 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -449,48 +449,6 @@ export function CollectionSubView<X>(moreProps?: X) {
this.slowLoadDocuments(files, options, generatedDocuments, text, completed, e.clientX, e.clientY, addDocument).then(batch.end);
}
- /**
- * Creates a placeholder doc view for files being uploaded and removes placeholder docs once files are uplodaded.
- *
- * @param files the files to upload that we want to create placeholders for
- * @param options the document options (primarily the x and y coordinates to put doc)
- * @param text in the case of youtube the text is the url to the video
- * @returns a disposer action that removes the placeholders created after files get uploaded
- */
- placeHolderDisposer = (files: File[] | string, options: DocumentOptions, text: string) => {
- // TODO: nda - create a specialized view for placeholder upload with a spinner and ability to retry upload
- let placeholders: Doc[] = [];
- // handle yt case
- if (typeof files === 'string') {
- placeholders.push(Docs.Create.LoadingDocument('Loading...', text, 500, 500, { ...options }));
- // placeholders.push(Docs.Create.TextDocument('Loading: ' + text, { ...options, title: text, _width: 400, _height: 30 }));
- } else {
- // every other doc type is an array of File
-
- // Get the file names as a text
- let textStr = '';
- files.forEach(file => {
- textStr += file.name + '\n';
- });
- placeholders.push(Docs.Create.LoadingDocument('Loading...', textStr, 500, 500, { ...options }));
-
- // placeholders.push(Docs.Create.TextDocument('Loading: \n' + textStr, { ...options, title: files.length + ' files', _width: 500, _height: files.length * 40 }));
- }
- // disposer action to remove placeholders once files are uploaded
- const remove = action(() => {
- if (!this.props.DataDoc) {
- return;
- }
- for (let i = 0; i < placeholders.length; i++) {
- Doc.RemoveDocFromList(this.props.DataDoc, 'data', placeholders[i]);
- }
- });
- placeholders.forEach(pl => {
- this.addDocument(pl);
- });
- return remove;
- };
-
slowLoadDocuments = async (
files: File[] | string,
options: DocumentOptions,
@@ -501,13 +459,31 @@ export function CollectionSubView<X>(moreProps?: X) {
clientY: number,
addDocument: (doc: Doc | Doc[]) => boolean
) => {
+ // create placeholder docs
+ // inside placeholder docs have some func that
+
// TODO: once loading thing is moved it should update the x and y of the file it is placeholder for
- const disposer = this.placeHolderDisposer(files, options, text);
+ let pileUpDoc = undefined;
// const disposer = OverlayView.Instance.addElement(<ReactLoading type={'spinningBubbles'} color={'green'} height={250} width={250} />, { x: clientX - 125, y: clientY - 125 });
if (typeof files === 'string') {
- generatedDocuments.push(...(await DocUtils.uploadYoutubeVideo(files, options)));
+ // uploadYoutubeVideo and similar should return a placeholder, one for each placeholder
+ // generatedDocuments.push(Docs.Create.LoadingDocument(files, options));
} else {
- generatedDocuments.push(...(await DocUtils.uploadFilesToDocs(files, options)));
+ // uploadFilesToDocs and similar should return a placeholder, one for each placeholder
+ generatedDocuments.push(
+ ...files.map(file => {
+ const loading = Docs.Create.LoadingDocument(file, options);
+ // now that there is a doc do whatever slowload was going to do with that file
+ if (typeof file === 'string') {
+ // uploadYoutubeVideo and similar should return a placeholder, one for each placeholder
+ // (await DocUtils.uploadYoutubeVideo(files, options)));
+ } else {
+ // uploadFilesToDocs and similar should return a placeholder, one for each placeholder
+ DocUtils.uploadFileToDoc(file, {}, loading);
+ }
+ return loading;
+ })
+ );
}
if (generatedDocuments.length) {
// Creating a dash document
@@ -523,7 +499,8 @@ export function CollectionSubView<X>(moreProps?: X) {
if (completed) completed(set);
else {
if (isFreeformView && generatedDocuments.length > 1) {
- addDocument(DocUtils.pileup(generatedDocuments, options.x as number, options.y as number)!);
+ pileUpDoc = DocUtils.pileup(generatedDocuments, options.x as number, options.y as number)!;
+ addDocument(pileUpDoc);
} else {
generatedDocuments.forEach(addDocument);
}
@@ -535,7 +512,6 @@ export function CollectionSubView<X>(moreProps?: X) {
alert('Document upload failed - possibly an unsupported file type.');
}
}
- disposer();
};
}