From 2b1850144eb647ec0f5be56cd9040bf835668e92 Mon Sep 17 00:00:00 2001
From: Tamara Steinwender <tamara.steinwender@tugraz.at>
Date: Wed, 5 Aug 2020 16:00:55 +0200
Subject: [PATCH] Fixed timing error, where this would be undefined

---
 packages/file-handling/src/dbp-nextcloud-file-picker.js | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/packages/file-handling/src/dbp-nextcloud-file-picker.js b/packages/file-handling/src/dbp-nextcloud-file-picker.js
index 7762e60d..8c19eacc 100644
--- a/packages/file-handling/src/dbp-nextcloud-file-picker.js
+++ b/packages/file-handling/src/dbp-nextcloud-file-picker.js
@@ -392,15 +392,18 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
             let path = directory + "/" + file.name;
             // https://github.com/perry-mitchell/webdav-client#putfilecontents
             let ret = false;
+            let that = this;
             let contents = await this.webDavClient
                     .putFileContents(path, file,  { overwrite: false, onUploadProgress: progress => {
                             console.log(`Uploaded ${progress.loaded} bytes of ${progress.total}`);
                         }}).then(function() {
-                            this.loading = false;
-                            this.statusText = "";
+
+                            that.loading = false;
+
+                            that.statusText = "";
                             console.log("try finished");
                             console.log("after one file finished");
-                            this.fileList.shift();
+                            that.fileList.shift();
                             console.log("FileList: ", this.fileList);
                             this.uploadFile(directory);
                         }).catch(error => {
-- 
GitLab