aboutsummaryrefslogtreecommitdiff
path: root/src/mobile/ImageUpload.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/mobile/ImageUpload.tsx')
-rw-r--r--src/mobile/ImageUpload.tsx38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx
index 16808a598..47b9d8f0b 100644
--- a/src/mobile/ImageUpload.tsx
+++ b/src/mobile/ImageUpload.tsx
@@ -7,7 +7,7 @@ import { Server } from '../client/Server';
import { Documents } from '../client/documents/Documents';
import { ListField } from '../fields/ListField';
import { ImageField } from '../fields/ImageField';
-import request = require('request');
+import * as rp from 'request-promise'
import { ServerUtils } from '../server/ServerUtil';
import { RouteStore } from '../server/RouteStore';
@@ -40,28 +40,24 @@ const onFileLoad = (file: any) => {
json.map((file: any) => {
let path = window.location.origin + file
var doc: Document = Documents.ImageDocument(path, { nativeWidth: 200, width: 200 })
- doc.GetTAsync(KeyStore.Data, ImageField, (i) => {
- if (i) {
- document.getElementById("message")!.innerText = i.Data.href;
+
+ rp.get(ServerUtils.prepend(RouteStore.getUserDocumentId)).then(res => {
+ if (res) {
+ return Server.GetField(res);
+ }
+ throw new Error("No user id returned");
+ }).then(field => {
+ if (field instanceof Document) {
+ return field.GetTAsync(KeyStore.OptionalRightCollection, Document)
}
- })
- request.get(ServerUtils.prepend(RouteStore.getActiveWorkspace), (error, response, body) => {
- if (body) {
- Server.GetField(body, field => {
- if (field instanceof Document) {
- field.GetTAsync(KeyStore.OptionalRightCollection, Document,
- pending => {
- if (pending) {
- pending.GetOrCreateAsync(KeyStore.Data, ListField, list => {
- list.Data.push(doc);
- })
- }
- })
- }
- }
- );
+ }).then(pending => {
+ if (pending) {
+ pending.GetOrCreateAsync(KeyStore.Data, ListField, list => {
+ list.Data.push(doc);
+ })
}
- })
+ });
+
// console.log(window.location.origin + file[0])
//imgPrev.setAttribute("src", window.location.origin + files[0].name)