From 517816327526520b99e439345b48549ebc79db6b Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Thu, 23 May 2019 01:24:15 -0400 Subject: More image upload changes --- src/mobile/ImageUpload.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx index 91a8858d8..bfc1738fc 100644 --- a/src/mobile/ImageUpload.tsx +++ b/src/mobile/ImageUpload.tsx @@ -27,10 +27,12 @@ const inputRef = React.createRef(); class Uploader extends React.Component { @observable error: string = ""; + @observable + status: string = ""; onClick = async () => { try { - this.error = "initializing protos"; + this.status = "initializing protos"; await Docs.initProtos(); let imgPrev = document.getElementById("img_preview"); if (imgPrev) { @@ -42,17 +44,18 @@ class Uploader extends React.Component { formData.append("file", files[0]); const upload = window.location.origin + "/upload"; - this.error = "uploading image"; + this.status = "uploading image"; const res = await fetch(upload, { method: 'POST', body: formData }); + this.status = "upload image, getting json"; const json = await res.json(); json.map(async (file: any) => { let path = window.location.origin + file; var doc = Docs.ImageDocument(path, { nativeWidth: 200, width: 200, title: name }); - this.error = "getting user document"; + this.status = "getting user document"; const res = await rp.get(DocServer.prepend(RouteStore.getUserDocumentId)); if (!res) { @@ -64,14 +67,14 @@ class Uploader extends React.Component { pending = await Cast(field.optionalRightCollection, Doc); } if (pending) { - this.error = "has pending docs"; + this.status = "has pending docs"; const data = await Cast(pending.data, listSpec(Doc)); if (data) { data.push(doc); } else { pending.data = new List([doc]); } - this.error = "finished"; + this.status = "finished"; } }); @@ -92,6 +95,7 @@ class Uploader extends React.Component { +

{this.status}

{this.error}

); -- cgit v1.2.3-70-g09d2