From 6499ac4b30c8f6ada2b0c7d74cd5f2a73f9bf180 Mon Sep 17 00:00:00 2001 From: bobzel Date: Sun, 10 Sep 2023 15:58:09 -0400 Subject: fixes for file uploads: restored progress for youtube videos, fixed info display on loadingBoxes, stop client from asking for progress on failed uploads. attempt to catch stream errors on webpages. fixed dataFieldView in text to print out layout document's field, not field of document that contains the field definition. --- src/client/Network.ts | 4 ++-- src/client/documents/Documents.ts | 2 +- src/client/views/nodes/LoadingBox.scss | 3 +++ src/client/views/nodes/LoadingBox.tsx | 4 ++-- src/client/views/nodes/formattedText/RichTextRules.ts | 9 +++------ 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/client') diff --git a/src/client/Network.ts b/src/client/Network.ts index 39bf69e32..631ec9122 100644 --- a/src/client/Network.ts +++ b/src/client/Network.ts @@ -74,10 +74,10 @@ export namespace Networking { return response.json(); } - export async function UploadYoutubeToServer(videoId: string): Promise[]> { + export async function UploadYoutubeToServer(videoId: string, overwriteId?: string): Promise[]> { const parameters = { method: 'POST', - body: JSON.stringify({ videoId }), + body: JSON.stringify({ videoId, overwriteId }), json: true, }; const response = await fetch('/uploadYoutubeVideo', parameters); diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 90c090f29..bb60cb329 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -1871,7 +1871,7 @@ export namespace DocUtils { export function uploadYoutubeVideoLoading(videoId: string, options: DocumentOptions, overwriteDoc?: Doc) { const generatedDocuments: Doc[] = []; - Networking.UploadYoutubeToServer(videoId).then(upfiles => { + Networking.UploadYoutubeToServer(videoId, overwriteDoc?.[Id]).then(upfiles => { const { source: { name, type }, result, diff --git a/src/client/views/nodes/LoadingBox.scss b/src/client/views/nodes/LoadingBox.scss index d4a7e18f2..61a505420 100644 --- a/src/client/views/nodes/LoadingBox.scss +++ b/src/client/views/nodes/LoadingBox.scss @@ -21,6 +21,7 @@ .textContainer { margin: 5px; + display: block; } .textContainer { @@ -31,6 +32,8 @@ .headerText { text-align: center; font-weight: bold; + height: auto; + width: 100%; } .spinner { diff --git a/src/client/views/nodes/LoadingBox.tsx b/src/client/views/nodes/LoadingBox.tsx index 0b02626e9..58c70bdd7 100644 --- a/src/client/views/nodes/LoadingBox.tsx +++ b/src/client/views/nodes/LoadingBox.tsx @@ -46,7 +46,7 @@ export class LoadingBox extends ViewBoxAnnotatableComponent() { const updateFunc = async () => { const result = await Networking.QueryYoutubeProgress(StrCast(this.rootDoc[Id])); // We use the guid of the overwriteDoc to track file uploads. runInAction(() => (this.progress = result.progress)); - this._timer = setTimeout(updateFunc, 1000); + !this.rootDoc.loadingError && (this._timer = setTimeout(updateFunc, 1000)); }; this._timer = setTimeout(updateFunc, 1000); } @@ -59,8 +59,8 @@ export class LoadingBox extends ViewBoxAnnotatableComponent() { return (
-

{StrCast(this.rootDoc.loadingError, 'Loading ' + (this.progress.replace('[download]', '') || '(can take several minutes)'))}

{StrCast(this.rootDoc.title)} +

{StrCast(this.rootDoc.loadingError, 'Loading ' + (this.progress.replace('[download]', '') || '(can take several minutes)'))}

{this.rootDoc.loadingError ? null : }
diff --git a/src/client/views/nodes/formattedText/RichTextRules.ts b/src/client/views/nodes/formattedText/RichTextRules.ts index 5d92f63ef..3e2afd2ce 100644 --- a/src/client/views/nodes/formattedText/RichTextRules.ts +++ b/src/client/views/nodes/formattedText/RichTextRules.ts @@ -279,12 +279,9 @@ export class RichTextRules { const num = value.match(/^[0-9.]$/); this.Document[DocData][fieldKey] = value === 'true' ? true : value === 'false' ? false : num ? Number(value) : value; } - const target = DocServer.FindDocByTitle(docTitle) ?? this.Document; - if (target) { - const fieldView = state.schema.nodes.dashField.create({ fieldKey, docId: target[Id], hideKey: false }); - return state.tr.setSelection(new TextSelection(state.doc.resolve(start), state.doc.resolve(end))).replaceSelectionWith(fieldView, true); - } - return state.tr; + const target = DocServer.FindDocByTitle(docTitle); + const fieldView = state.schema.nodes.dashField.create({ fieldKey, docId: target?.[Id], hideKey: false }); + return state.tr.setSelection(new TextSelection(state.doc.resolve(start), state.doc.resolve(end))).replaceSelectionWith(fieldView, true); }), // create a text display of a metadata field on this or another document, or create a hyperlink portal to another document -- cgit v1.2.3-70-g09d2