REFACTOR: Remove container from pwa-utils

REFACTOR: Remove container from pwa-utils

diff --git a/app/assets/javascripts/discourse/app/components/invite-panel.js b/app/assets/javascripts/discourse/app/components/invite-panel.js
index 42308e2..76d8481 100644
--- a/app/assets/javascripts/discourse/app/components/invite-panel.js
+++ b/app/assets/javascripts/discourse/app/components/invite-panel.js
@@ -1,7 +1,7 @@
 import I18n from "I18n";
 import discourseComputed from "discourse-common/utils/decorators";
 import { isEmpty } from "@ember/utils";
-import EmberObject, { action, computed } from "@ember/object";
+import EmberObject, { action } from "@ember/object";
 import { alias, and, equal } from "@ember/object/computed";
 import Component from "@ember/component";
 import { emailValid } from "discourse/lib/utilities";
@@ -189,10 +189,6 @@ export default Component.extend({
     );
   },
 
-  showContactPicker: computed(function() {
-    return this.capabilities.hasContactPicker;
-  }),
-
   @discourseComputed("emailOrUsername")
   showCustomMessage(emailOrUsername) {
     return this.inviteModel === this.currentUser || emailValid(emailOrUsername);
@@ -454,7 +450,7 @@ export default Component.extend({
 
   @action
   searchContact() {
-    getNativeContact(["email"], false).then(result => {
+    getNativeContact(this.capabilities, ["email"], false).then(result => {
       this.set("emailOrUsername", result[0].email[0]);
     });
   }
diff --git a/app/assets/javascripts/discourse/app/components/share-popup.js b/app/assets/javascripts/discourse/app/components/share-popup.js
index 580a6c9..810a9d5 100644
--- a/app/assets/javascripts/discourse/app/components/share-popup.js
+++ b/app/assets/javascripts/discourse/app/components/share-popup.js
@@ -134,7 +134,9 @@ export default Component.extend({
 
     // use native webshare only when the user clicks on the "chain" icon
     if (!$currentTarget.hasClass("post-date")) {
-      nativeShare({ url }).then(null, () => this._showUrl($currentTarget, url));
+      nativeShare(this.capabilities, { url }).then(null, () =>
+        this._showUrl($currentTarget, url)
+      );
     } else {
       this._showUrl($currentTarget, url);
     }
diff --git a/app/assets/javascripts/discourse/app/lib/pwa-utils.js b/app/assets/javascripts/discourse/app/lib/pwa-utils.js
index 23746a0..84f4bff 100644
--- a/app/assets/javascripts/discourse/app/lib/pwa-utils.js
+++ b/app/assets/javascripts/discourse/app/lib/pwa-utils.js
@@ -1,7 +1,6 @@
 import { Promise } from "rsvp";
 
-export function nativeShare(data) {
-  const caps = Discourse.__container__.lookup("capabilities:main");
+export function nativeShare(caps, data) {
   return new Promise((resolve, reject) => {
     if (!(caps.isIOS || caps.isAndroid || caps.isWinphone)) {
       reject();
@@ -27,12 +26,10 @@ export function nativeShare(data) {
   });
 }
 
-export function getNativeContact(properties, multiple) {
-  const caps = Discourse.__container__.lookup("capabilities:main");
+export function getNativeContact(caps, properties, multiple) {
   return new Promise((resolve, reject) => {
     if (!caps.hasContactPicker) {
-      reject();
-      return;
+      return reject();
     }
 
     navigator.contacts
diff --git a/app/assets/javascripts/discourse/app/templates/components/invite-panel.hbs b/app/assets/javascripts/discourse/app/templates/components/invite-panel.hbs
index a014db3..c4bff57 100644
--- a/app/assets/javascripts/discourse/app/templates/components/invite-panel.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/invite-panel.hbs
@@ -38,7 +38,7 @@
             value=emailOrUsername
             placeholderKey="topic.invite_reply.email_placeholder"}}
         {{/if}}
-        {{#if showContactPicker}}
+        {{#if capabilities.hasContactPicker}}
           {{d-button
             icon="address-book"
             action=(action "searchContact")

GitHub sha: c7c3fd42

This commit appears in #10480 which was merged by eviltrout.