FIX: errors in Ember CLI (#98)

FIX: errors in Ember CLI (#98)

Can’t access Discourse.SiteSettings, so pass it in.

diff --git a/assets/javascripts/discourse/connectors/composer-action-after/encrypt.js.es6 b/assets/javascripts/discourse/connectors/composer-action-after/encrypt.js.es6
index ca7231e..f5f3e74 100644
--- a/assets/javascripts/discourse/connectors/composer-action-after/encrypt.js.es6
+++ b/assets/javascripts/discourse/connectors/composer-action-after/encrypt.js.es6
@@ -9,7 +9,7 @@ import {
 export default {
   setupComponent(args, component) {
     const currentUser = getOwner(component).lookup("current-user:main");
-    const status = getEncryptionStatus(currentUser);
+    const status = getEncryptionStatus(currentUser, component.siteSettings);
 
     component.setProperties({
       isEncryptEnabled: status !== ENCRYPT_DISABLED,
@@ -17,7 +17,10 @@ export default {
 
       /** Listens for encryption status updates. */
       listener() {
-        const newStatus = getEncryptionStatus(currentUser);
+        const newStatus = getEncryptionStatus(
+          currentUser,
+          component.siteSettings
+        );
         component.setProperties({
           isEncryptEnabled: newStatus !== ENCRYPT_DISABLED,
           isEncryptActive: newStatus === ENCRYPT_ACTIVE,
diff --git a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6 b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
index 7df05a1..0ed7744 100644
--- a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
+++ b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
@@ -32,13 +32,13 @@ export default {
       /** Whether current user is the same as model user. */
       isCurrentUser,
       /** Whether plugin is enabled for current user. */
-      canEnableEncrypt: canEnableEncrypt(args.model),
+      canEnableEncrypt: canEnableEncrypt(args.model, component.siteSettings),
       /** Whether the encryption is enabled or not. */
       isEncryptEnabled: !!args.model.encrypt_public,
     });
 
     if (isCurrentUser) {
-      const status = getEncryptionStatus(args.model);
+      const status = getEncryptionStatus(args.model, component.siteSettings);
       component.setProperties({
         /** Value of passphrase input.
          *  It should stay in memory for as little time as possible.
@@ -59,7 +59,10 @@ export default {
         isEncryptActive: status === ENCRYPT_ACTIVE,
         /** Listens for encryption status updates. */
         listener() {
-          const newStatus = getEncryptionStatus(args.model);
+          const newStatus = getEncryptionStatus(
+            args.model,
+            component.siteSettings
+          );
           component.setProperties({
             isEncryptEnabled: newStatus !== ENCRYPT_DISABLED,
             isEncryptActive: newStatus === ENCRYPT_ACTIVE,
diff --git a/assets/javascripts/discourse/initializers/auto-enable-encrypt.js.es6 b/assets/javascripts/discourse/initializers/auto-enable-encrypt.js.es6
index 46772cc..dc00682 100644
--- a/assets/javascripts/discourse/initializers/auto-enable-encrypt.js.es6
+++ b/assets/javascripts/discourse/initializers/auto-enable-encrypt.js.es6
@@ -19,7 +19,7 @@ export default {
     if (currentUser) {
       if (
         !window.localStorage.getItem(AUTO_ENABLE_KEY) &&
-        getEncryptionStatus(currentUser) === ENCRYPT_DISABLED
+        getEncryptionStatus(currentUser, siteSettings) === ENCRYPT_DISABLED
       ) {
         window.localStorage.setItem(AUTO_ENABLE_KEY, true);
         enableEncrypt(currentUser).then(() => {
diff --git a/assets/javascripts/discourse/initializers/hook-composer.js.es6 b/assets/javascripts/discourse/initializers/hook-composer.js.es6
index 6ad77ce..ba10eae 100644
--- a/assets/javascripts/discourse/initializers/hook-composer.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-composer.js.es6
@@ -24,7 +24,8 @@ export default {
 
   initialize(container) {
     const currentUser = container.lookup("current-user:main");
-    if (getEncryptionStatus(currentUser) !== ENCRYPT_ACTIVE) {
+    const siteSettings = container.lookup("site-settings:main");
+    if (getEncryptionStatus(currentUser, siteSettings) !== ENCRYPT_ACTIVE) {
       return;
     }
 
diff --git a/assets/javascripts/discourse/initializers/hook-decrypt-post.js.es6 b/assets/javascripts/discourse/initializers/hook-decrypt-post.js.es6
index 51a16dc..b6a2bde 100644
--- a/assets/javascripts/discourse/initializers/hook-decrypt-post.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-decrypt-post.js.es6
@@ -273,7 +273,8 @@ export default {
 
   initialize(container) {
     const currentUser = container.lookup("current-user:main");
-    if (getEncryptionStatus(currentUser) === ENCRYPT_DISABLED) {
+    const siteSettings = container.lookup("site-settings:main");
+    if (getEncryptionStatus(currentUser, siteSettings) === ENCRYPT_DISABLED) {
       return;
     }
 
@@ -282,8 +283,7 @@ export default {
 
       api.includePostAttributes("encrypted_raw");
 
-      api.decorateWidget("post-contents:after-cooked", (dec) => {
-        const siteSettings = dec.widget.siteSettings;
+      api.decorateWidget("post-contents:after-cooked", () => {
         $(".cooked img")
           .not($(".d-lazyload-hidden"))
           .not($("a.lightbox img"))
diff --git a/assets/javascripts/discourse/initializers/hook-decrypt-revision.js.es6 b/assets/javascripts/discourse/initializers/hook-decrypt-revision.js.es6
index 030a0be..077ba84 100644
--- a/assets/javascripts/discourse/initializers/hook-decrypt-revision.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-decrypt-revision.js.es6
@@ -14,7 +14,8 @@ export default {
 
   initialize(container) {
     const currentUser = container.lookup("current-user:main");
-    if (getEncryptionStatus(currentUser) !== ENCRYPT_ACTIVE) {
+    const siteSettings = container.lookup("site-settings:main");
+    if (getEncryptionStatus(currentUser, siteSettings) !== ENCRYPT_ACTIVE) {
       return;
     }
 
diff --git a/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6 b/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
index 878068e..ce5d49a 100644
--- a/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
@@ -69,7 +69,8 @@ export default {
 
   initialize(container) {
     const currentUser = container.lookup("current-user:main");
-    if (getEncryptionStatus(currentUser) !== ENCRYPT_ACTIVE) {
+    const siteSettings = container.lookup("site-settings:main");
+    if (getEncryptionStatus(currentUser, siteSettings) !== ENCRYPT_ACTIVE) {
       return;
     }
 
diff --git a/assets/javascripts/discourse/initializers/hook-draft.js.es6 b/assets/javascripts/discourse/initializers/hook-draft.js.es6
index c5f4cb3..48fa8ff 100644
--- a/assets/javascripts/discourse/initializers/hook-draft.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-draft.js.es6
@@ -34,7 +34,8 @@ export default {
 
   initialize(container) {
     const currentUser = container.lookup("current-user:main");
-    if (getEncryptionStatus(currentUser) !== ENCRYPT_ACTIVE) {
+    const siteSettings = container.lookup("site-settings:main");
+    if (getEncryptionStatus(currentUser, siteSettings) !== ENCRYPT_ACTIVE) {
       return;
     }
 
diff --git a/assets/javascripts/discourse/initializers/hook-encrypt-upload.js.es6 b/assets/javascripts/discourse/initializers/hook-encrypt-upload.js.es6
index 7b36756..f8e23de 100644
--- a/assets/javascripts/discourse/initializers/hook-encrypt-upload.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-encrypt-upload.js.es6
@@ -19,7 +19,8 @@ export default {
 
   initialize(container) {
     const currentUser = container.lookup("current-user:main");
-    if (getEncryptionStatus(currentUser) !== ENCRYPT_ACTIVE) {
+    const siteSettings = container.lookup("site-settings:main");
+    if (getEncryptionStatus(currentUser, siteSettings) !== ENCRYPT_ACTIVE) {

[... diff too long, it was truncated ...]

GitHub sha: 619eeaf5

This commit appears in #98 which was approved by CvX. It was merged by nlalonde.