Bug 1563633 - Port bug 1558602: Use new API for sync calls to Fluent in OTR chat. r=aleca
authorKai Engert <kaie@kuix.de>
Fri, 05 Jul 2019 23:25:18 +0200
changeset 36040 8da790400467339fff4f0954284c9ac69b98c7e8
parent 36039 83dd4afa641fe1128d23b004fc59d97d2829f974
child 36041 22be14b4e4fac49c2af45d306ac19b96b8e1e60b
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersaleca
bugs1563633, 1558602
Bug 1563633 - Port bug 1558602: Use new API for sync calls to Fluent in OTR chat. r=aleca
chat/content/otr-finger.js
chat/modules/OTR.jsm
chat/modules/OTRUI.jsm
--- a/chat/content/otr-finger.js
+++ b/chat/content/otr-finger.js
@@ -1,37 +1,36 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const {Services} = ChromeUtils.import("resource:///modules/imServices.jsm");
 const {OTR} = ChromeUtils.import("resource:///modules/OTR.jsm");
-const {LocalizationSync} =
-  ChromeUtils.import("resource://gre/modules/Localization.jsm", {});
+const {Localization} = ChromeUtils.import("resource://gre/modules/Localization.jsm");
 
-const syncL10n = new LocalizationSync([
+const syncL10n = new Localization([
   "messenger/otr/finger.ftl",
-]);
+], true);
 
 var [account] = window.arguments;
 
 var gFingers;
 var fingerTreeView = {
   selection: null,
   rowCount: 0,
   setTree(tree) {},
   getImageSrc(row, column) {},
   getProgressMode(row, column) {},
   getCellValue(row, column) {},
   getCellText(row, column) {
     let finger = gFingers[row];
     switch (column.id) {
       case "verified": {
         let id = finger.trust ? "finger-yes" : "finger-no";
-        return syncL10n.formatValue(id);
+        return syncL10n.formatValueSync(id);
       }
       default:
         return finger[column.id] || "";
     }
   },
   isSeparator(index) { return false; },
   isSorted() { return false; },
   isContainer(index) { return false; },
@@ -78,18 +77,18 @@ var otrFinger = {
     // mark fingers for removal
     getSelections(fingerTree).forEach(function(sel) {
       gFingers[sel].purge = true;
     });
     this.commonRemove();
   },
 
   removeAll() {
-    let confirmAllTitle = syncL10n.formatValue("finger-remove-all-title");
-    let confirmAllText = syncL10n.formatValue("finger-remove-all-message");
+    let confirmAllTitle = syncL10n.formatValueSync("finger-remove-all-title");
+    let confirmAllText = syncL10n.formatValueSync("finger-remove-all-message");
 
     let buttonPressed =
       Services.prompt.confirmEx(window, confirmAllTitle, confirmAllText,
         Services.prompt.BUTTON_POS_1_DEFAULT +
           Services.prompt.STD_OK_CANCEL_BUTTONS +
           Services.prompt.BUTTON_DELAY_ENABLE,
         0, 0, 0, null, {});
     if (buttonPressed != 0) {
@@ -113,14 +112,14 @@ var otrFinger = {
         }
         gFingers.splice(j, k - j);
         fingerTreeView.rowCount -= k - j;
         fingerTree.rowCountChanged(j, j - k);  // negative
       }
     }
     fingerTreeView.selection.selectEventsSuppressed = false;
     if (!removalComplete) {
-      let infoTitle = syncL10n.formatValue("finger-subset-title");
-      let infoText = syncL10n.formatValue("finger-subset-message");
+      let infoTitle = syncL10n.formatValueSync("finger-subset-title");
+      let infoText = syncL10n.formatValueSync("finger-subset-message");
       Services.prompt.alert(window, infoTitle, infoText);
     }
   },
 };
--- a/chat/modules/OTR.jsm
+++ b/chat/modules/OTR.jsm
@@ -1,33 +1,32 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-const { LocalizationSync } =
-  ChromeUtils.import("resource://gre/modules/Localization.jsm", {});
+const {Localization} = ChromeUtils.import("resource://gre/modules/Localization.jsm");
 const {BasePromiseWorker} = ChromeUtils.import("resource://gre/modules/PromiseWorker.jsm");
 const {OS} = ChromeUtils.import("resource://gre/modules/osfile.jsm");
 const {ctypes} = ChromeUtils.import("resource://gre/modules/ctypes.jsm");
 const {Services} = ChromeUtils.import("resource:///modules/imServices.jsm");
 const {CLib} = ChromeUtils.import("resource:///modules/CLib.jsm");
 const {OTRLibLoader} = ChromeUtils.import("resource:///modules/OTRLib.jsm");
 var workerPath = "chrome://chat/content/otrWorker.js";
 const {OTRHelpers} = ChromeUtils.import("resource:///modules/OTRHelpers.jsm");
 
-const syncL10n = new LocalizationSync([
+const syncL10n = new Localization([
   "messenger/otr/otr.ftl",
-]);
+], true);
 
 function _str(id) {
-  return syncL10n.formatValue(id);
+  return syncL10n.formatValueSync(id);
 }
 
 function _strArgs(id, args) {
-  return syncL10n.formatValue(id, args);
+  return syncL10n.formatValueSync(id, args);
 }
 
 // some helpers
 
 function setInterval(fn, delay) {
   let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
   timer.init(fn, delay, Ci.nsITimer.TYPE_REPEATING_SLACK);
   return timer;
--- a/chat/modules/OTRUI.jsm
+++ b/chat/modules/OTRUI.jsm
@@ -1,29 +1,28 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 this.EXPORTED_SYMBOLS = ["OTRUI"];
 
-const { LocalizationSync } =
-  ChromeUtils.import("resource://gre/modules/Localization.jsm", {});
+const {Localization} = ChromeUtils.import("resource://gre/modules/Localization.jsm");
 const {Services} = ChromeUtils.import("resource:///modules/imServices.jsm");
 const {OTR}  = ChromeUtils.import("resource:///modules/OTR.jsm");
 
-const syncL10n = new LocalizationSync([
+const syncL10n = new Localization([
   "messenger/otr/otrUI.ftl",
-]);
+], true);
 
 function _str(id) {
-  return syncL10n.formatValue(id);
+  return syncL10n.formatValueSync(id);
 }
 
 function _strArgs(id, args) {
-  return syncL10n.formatValue(id, args);
+  return syncL10n.formatValueSync(id, args);
 }
 
 const OTR_AUTH_DIALOG_URL = "chrome://chat/content/otr-auth.xul";
 const OTR_ADD_FINGER_DIALOG_URL = "chrome://chat/content/otr-add-fingerprint.xul";
 
 const AUTH_STATUS_UNVERIFIED = "otr-auth-unverified";
 var authLabelMap;
 var authTitleMap;
@@ -397,19 +396,19 @@ var OTRUI = {
         OTRUI.noOtrPossible(otrContainer, context);
         return;
       }
       if (addSystemMessage) {
         let trust = OTRUI.getTrustSettings(context);
         let id = "state-" + trust.class;
         let msg;
         if (OTR.trust(context) == OTR.trustState.TRUST_NOT_PRIVATE) {
-          msg = syncL10n.formatValue(id);
+          msg = syncL10n.formatValueSync(id);
         } else {
-          msg = syncL10n.formatValue(id, {name: context.username});
+          msg = syncL10n.formatValueSync(id, {name: context.username});
         }
         uiConv.systemMessage(msg);
       }
     } catch (e) {
       OTRUI.noOtrPossible(otrContainer, context);
       return;
     }
 
@@ -506,17 +505,17 @@ var OTRUI = {
         // prevent closing of notification bar when the button is hit
         return true;
       },
     }];
 
     let priority = this.globalBox.PRIORITY_WARNING_MEDIUM;
     this.globalBox.appendNotification(msg, context.username, null, priority, buttons, null);
 
-    let verifyTitle = syncL10n.formatValue("verify-title");
+    let verifyTitle = syncL10n.formatValueSync("verify-title");
     this.updateNotificationUI(context, verifyTitle, context.username, AUTH_STATUS_UNVERIFIED);
 
     if (context.username !== this.visibleConv.normalizedName) {
       this.hideUserNotifications(context);
     }
   },
 
   updateNotificationUI(context, typeTitle, username, key) {