From 9a9524b4c6e2980eb37ece288890d6cb746eb81c Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Mon, 27 Jan 2020 17:10:34 -0500 Subject: factored out icon names --- src/client/views/nodes/ImageBox.tsx | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx index 3f25faae6..ffcbe459e 100644 --- a/src/client/views/nodes/ImageBox.tsx +++ b/src/client/views/nodes/ImageBox.tsx @@ -58,7 +58,12 @@ declare class MediaRecorder { type ImageDocument = makeInterface<[typeof pageSchema, typeof documentSchema]>; const ImageDocument = makeInterface(pageSchema, documentSchema); -const defaultUploadIcon = "downarrow.png"; +const uploadIcons = { + idle: "downarrow.png", + loading: "loading.gif", + success: "greencheck.png", + failure: "redx.png" +}; @observer export class ImageBox extends DocAnnotatableComponent(ImageDocument) { @@ -67,7 +72,7 @@ export class ImageBox extends DocAnnotatableComponent { this._dropDisposer && this._dropDisposer(); @@ -311,19 +316,20 @@ export class ImageBox extends DocAnnotatableComponent { const { dataDoc } = this; - runInAction(() => this.uploadIcon = "loading.gif"); + const { success, failure, idle, loading } = uploadIcons; + runInAction(() => this.uploadIcon = loading); const [{ clientAccessPath }] = await Networking.PostToServer("/uploadRemoteImage", { sources: [primary] }); dataDoc.originalUrl = primary; - let success = true; + let succeeded = true; let data: ImageField | undefined; try { - data = new ImageField(clientAccessPath); + data = new ImageField(Utils.prepend(clientAccessPath)); } catch { - success = false; + succeeded = false; } - runInAction(() => this.uploadIcon = success ? "greencheck.png" : "redx.png"); + runInAction(() => this.uploadIcon = succeeded ? success : failure); setTimeout(action(() => { - this.uploadIcon = defaultUploadIcon; + this.uploadIcon = idle; if (data) { dataDoc[this.props.fieldKey] = data; } -- cgit v1.2.3-70-g09d2