From 875442f1cec4d16b42f46c83cc702c5b50460e46 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Thu, 20 Jul 2023 21:08:39 +0200 Subject: [PATCH] removing Utils.getCurrentSetting() and use ReactiveCache directly --- client/components/main/layouts.js | 4 ++-- client/components/settings/invitationCode.js | 4 +++- client/components/settings/settingBody.js | 12 ++++++------ client/components/users/userHeader.js | 2 +- client/config/blazeHelpers.js | 2 +- client/lib/spinner.js | 4 +++- client/lib/utils.js | 4 ---- models/users.js | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/client/components/main/layouts.js b/client/components/main/layouts.js index f4d0bdf4a..2b140e0e4 100644 --- a/client/components/main/layouts.js +++ b/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 = "" + 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 = "" + currSetting.oidcBtnText; diff --git a/client/components/settings/invitationCode.js b/client/components/settings/invitationCode.js index 3bbc2ffcc..dbf7737c4 100644 --- a/client/components/settings/invitationCode.js +++ b/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(); diff --git a/client/components/settings/settingBody.js b/client/components/settings/settingBody.js index 435073221..8cb782933 100644 --- a/client/components/settings/settingBody.js +++ b/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, diff --git a/client/components/users/userHeader.js b/client/components/users/userHeader.js index 44d8ed02b..a4cc10b40 100644 --- a/client/components/users/userHeader.js +++ b/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) { diff --git a/client/config/blazeHelpers.js b/client/config/blazeHelpers.js index e35cd78c1..5ac27f3bf 100644 --- a/client/config/blazeHelpers.js +++ b/client/config/blazeHelpers.js @@ -19,7 +19,7 @@ Blaze.registerHelper('currentList', () => { }); Blaze.registerHelper('currentSetting', () => { - const ret = Utils.getCurrentSetting(); + const ret = ReactiveCache.getCurrentSetting(); return ret; }); diff --git a/client/lib/spinner.js b/client/lib/spinner.js index bbfdb1e74..f13d8478d 100644 --- a/client/lib/spinner.js +++ b/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; diff --git a/client/lib/utils.js b/client/lib/utils.js index 32072d34d..cfc313f62 100644 --- a/client/lib/utils.js +++ b/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); diff --git a/models/users.js b/models/users.js index 9191c13b8..0f5587420 100644 --- a/models/users.js +++ b/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) {