浏览代码

removing Utils.getCurrentSetting() and use ReactiveCache directly

Martin Filser 1 年之前
父节点
当前提交
875442f1ce

+ 2 - 2
client/components/main/layouts.js

@@ -161,7 +161,7 @@ Template.userFormsLayout.events({
   },
   'DOMSubtreeModified #at-oidc'(event) {
     if (alreadyCheck <= 2) {
-      let currSetting = Utils.getCurrentSetting();
+      let currSetting = ReactiveCache.getCurrentSetting();
       let oidcBtnElt = $("#at-oidc");
       if (currSetting && currSetting !== undefined && currSetting.oidcBtnText !== undefined && oidcBtnElt != null && oidcBtnElt != undefined) {
         let htmlvalue = "<i class='fa fa-oidc'></i>" + currSetting.oidcBtnText;
@@ -182,7 +182,7 @@ Template.userFormsLayout.events({
   'DOMSubtreeModified .at-form'(event) {
     if (alreadyCheck <= 2 && !isCheckDone) {
       if (document.getElementById("at-oidc") != null) {
-        let currSetting = Utils.getCurrentSetting();
+        let currSetting = ReactiveCache.getCurrentSetting();
         let oidcBtnElt = $("#at-oidc");
         if (currSetting && currSetting !== undefined && currSetting.oidcBtnText !== undefined && oidcBtnElt != null && oidcBtnElt != undefined) {
           let htmlvalue = "<i class='fa fa-oidc'></i>" + currSetting.oidcBtnText;

+ 3 - 1
client/components/settings/invitationCode.js

@@ -1,7 +1,9 @@
+import { ReactiveCache } from '/imports/reactiveCache';
+
 Template.invitationCode.onRendered(function() {
   Meteor.subscribe('setting', {
     onReady() {
-      const setting = Utils.getCurrentSetting();
+      const setting = ReactiveCache.getCurrentSetting();
 
       if (!setting || !setting.disableRegistration) {
         $('#invitationcode').hide();

+ 6 - 6
client/components/settings/settingBody.js

@@ -58,16 +58,16 @@ BlazeComponent.extendComponent({
   },
   toggleForgotPassword() {
     this.setLoading(true);
-    const forgotPasswordClosed = Utils.getCurrentSetting().disableForgotPassword;
-    Settings.update(Utils.getCurrentSetting()._id, {
+    const forgotPasswordClosed = ReactiveCache.getCurrentSetting().disableForgotPassword;
+    Settings.update(ReactiveCache.getCurrentSetting()._id, {
       $set: { disableForgotPassword: !forgotPasswordClosed },
     });
     this.setLoading(false);
   },
   toggleRegistration() {
     this.setLoading(true);
-    const registrationClosed = Utils.getCurrentSetting().disableRegistration;
-    Settings.update(Utils.getCurrentSetting()._id, {
+    const registrationClosed = ReactiveCache.getCurrentSetting().disableRegistration;
+    Settings.update(ReactiveCache.getCurrentSetting()._id, {
       $set: { disableRegistration: !registrationClosed },
     });
     this.setLoading(false);
@@ -163,7 +163,7 @@ BlazeComponent.extendComponent({
         .trim();
       const from = this.checkField('#mail-server-from');
       const tls = $('#mail-server-tls.is-checked').length > 0;
-      Settings.update(Utils.getCurrentSetting()._id, {
+      Settings.update(ReactiveCache.getCurrentSetting()._id, {
         $set: {
           'mailServer.host': host,
           'mailServer.port': port,
@@ -243,7 +243,7 @@ BlazeComponent.extendComponent({
     const spinnerName = $('#spinnerName').val();
 
     try {
-      Settings.update(Utils.getCurrentSetting()._id, {
+      Settings.update(ReactiveCache.getCurrentSetting()._id, {
         $set: {
           productName,
           hideLogo: hideLogoChange,

+ 1 - 1
client/components/users/userHeader.js

@@ -32,7 +32,7 @@ Template.memberMenuPopup.helpers({
     }
   },
   isSameDomainNameSettingValue(){
-    const currSett = Utils.getCurrentSetting();
+    const currSett = ReactiveCache.getCurrentSetting();
     if(currSett && currSett != undefined && currSett.disableRegistration && currSett.mailDomainName !== undefined && currSett.mailDomainName != ""){
       currentUser = ReactiveCache.getCurrentUser();
       if (currentUser) {

+ 1 - 1
client/config/blazeHelpers.js

@@ -19,7 +19,7 @@ Blaze.registerHelper('currentList', () => {
 });
 
 Blaze.registerHelper('currentSetting', () => {
-  const ret = Utils.getCurrentSetting();
+  const ret = ReactiveCache.getCurrentSetting();
   return ret;
 });
 

+ 3 - 1
client/lib/spinner.js

@@ -1,3 +1,5 @@
+import { ReactiveCache } from '/imports/reactiveCache';
+
 Meteor.subscribe('setting');
 
 import { ALLOWED_WAIT_SPINNERS } from '/config/const';
@@ -9,7 +11,7 @@ export class Spinner extends BlazeComponent {
     if (defaultWaitSpinner && ALLOWED_WAIT_SPINNERS.includes(defaultWaitSpinner)) {
       ret = defaultWaitSpinner;
     }
-    let settings = Utils.getCurrentSetting();
+    let settings = ReactiveCache.getCurrentSetting();
 
     if (settings && settings.spinnerName) {
       ret = settings.spinnerName;

+ 0 - 4
client/lib/utils.js

@@ -58,10 +58,6 @@ Utils = {
     }
     return ret;
   },
-  getCurrentSetting() {
-    const ret = ReactiveCache.getCurrentSetting();
-    return ret;
-  },
   getPopupCard() {
     const cardId = Utils.getPopupCardId();
     const ret = ReactiveCache.getCard(cardId);

+ 1 - 1
models/users.js

@@ -1956,7 +1956,7 @@ if (Meteor.isServer) {
     }
 
     //invite user to corresponding boards
-    const disableRegistration = Utils.getCurrentSetting().disableRegistration;
+    const disableRegistration = ReactiveCache.getCurrentSetting().disableRegistration;
     // If ldap, bypass the inviation code if the self registration isn't allowed.
     // TODO : pay attention if ldap field in the user model change to another content ex : ldap field to connection_type
     if (doc.authenticationMethod !== 'ldap' && disableRegistration) {