DEV: Review fixes from previous commit (#143)

DEV: Review fixes from previous commit (#143)

@udan11 added review comments post-merge to https://github.com/discourse/discourse-encrypt/pull/131, they are being resolved in this commit

diff --git a/assets/javascripts/discourse/initializers/encrypt-uploads.js b/assets/javascripts/discourse/initializers/encrypt-uploads.js
index 8dcc361..1143bc8 100644
--- a/assets/javascripts/discourse/initializers/encrypt-uploads.js
+++ b/assets/javascripts/discourse/initializers/encrypt-uploads.js
@@ -73,24 +73,24 @@ export default {
       const metadataPromise = getMetadata(file, siteSettings);
       const plaintextPromise = readFile(file);
       const keyPromise = generateUploadKey();
-      const exportedKeyPromise = keyPromise.then((key) => {
-        return window.crypto.subtle
+      const exportedKeyPromise = keyPromise.then((key) =>
+        window.crypto.subtle
           .exportKey("raw", key)
-          .then((wrapped) => bufferToBase64(wrapped));
-      });
+          .then((wrapped) => bufferToBase64(wrapped))
+      );
 
       const iv = window.crypto.getRandomValues(new Uint8Array(12));
 
       const ciphertextPromise = Promise.all([
         plaintextPromise,
         keyPromise,
-      ]).then(([plaintext, key]) => {
-        return window.crypto.subtle.encrypt(
+      ]).then(([plaintext, key]) =>
+        window.crypto.subtle.encrypt(
           { name: "AES-GCM", iv, tagLength: 128 },
           key,
           plaintext
-        );
-      });
+        )
+      );
 
       Promise.all([
         ciphertextPromise,
diff --git a/assets/javascripts/lib/uppy-upload-encrypt-plugin.js b/assets/javascripts/lib/uppy-upload-encrypt-plugin.js
index 91abc36..0d56bc9 100644
--- a/assets/javascripts/lib/uppy-upload-encrypt-plugin.js
+++ b/assets/javascripts/lib/uppy-upload-encrypt-plugin.js
@@ -1,8 +1,8 @@
 import { hasTopicKey } from "discourse/plugins/discourse-encrypt/lib/discourse";
+import { Promise } from "rsvp";
 import { bufferToBase64 } from "discourse/plugins/discourse-encrypt/lib/base64";
 import { UploadPreProcessorPlugin } from "discourse/lib/uppy-plugin-base";
 import { HUGE_FILE_THRESHOLD_BYTES } from "discourse/mixins/uppy-upload";
-
 import {
   generateUploadKey,
   getMetadata,
@@ -20,7 +20,7 @@ export default class UppyUploadEncrypt extends UploadPreProcessorPlugin {
   }
 
   async _encryptFile(fileId) {
-    let file = this._getFile(fileId);
+    const file = this._getFile(fileId);
 
     if (file.size > HUGE_FILE_THRESHOLD_BYTES) {
       return this._emitError(
@@ -76,13 +76,8 @@ export default class UppyUploadEncrypt extends UploadPreProcessorPlugin {
       return this._skipAll(fileIds, true);
     }
 
-    let encryptTasks = fileIds.map((fileId) => () =>
-      this._encryptFile.call(this, fileId)
-    );
-
-    for (const task of encryptTasks) {
-      await task();
-    }
+    const encryptPromises = fileIds.map((fileId) => this._encryptFile(fileId));
+    return Promise.all(encryptPromises);
   }
 
   install() {

GitHub sha: 7b1164959c3086adc419a3775a37d51053029d5a

This commit appears in #143 which was approved by eviltrout. It was merged by martin.