From 6385daebb5c8a56c2f999e2fda74a4fe16d61e5c Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 6 Jul 2021 13:22:38 -0300 Subject: [PATCH] [FIX] Subscribe to settings making app to hang on login (#3254) --- app/lib/methods/getSettings.js | 5 ++++- app/lib/rocketchat.js | 3 ++- app/sagas/login.js | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/lib/methods/getSettings.js b/app/lib/methods/getSettings.js index f68995af..c51ac406 100644 --- a/app/lib/methods/getSettings.js +++ b/app/lib/methods/getSettings.js @@ -131,6 +131,10 @@ export async function setSettings() { reduxStore.dispatch(addSettings(RocketChat.parseSettings(parsed.slice(0, parsed.length)))); } +export function subscribeSettings() { + return RocketChat.subscribe('stream-notify-all', 'public-settings-changed'); +} + export default async function() { try { const db = database.active; @@ -146,7 +150,6 @@ export default async function() { const filteredSettingsIds = filteredSettings.map(s => s._id); reduxStore.dispatch(addSettings(this.parseSettings(filteredSettings))); - RocketChat.subscribe('stream-notify-all', 'public-settings-changed'); // filter server info const serverInfo = filteredSettings.filter(i1 => serverInfoKeys.includes(i1._id)); diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 1cc0d4e0..5b69b92b 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -28,7 +28,7 @@ import getUsersPresence, { getUserPresence, subscribeUsersPresence } from './met import protectedFunction from './methods/helpers/protectedFunction'; import readMessages from './methods/readMessages'; -import getSettings, { getLoginSettings, setSettings } from './methods/getSettings'; +import getSettings, { getLoginSettings, setSettings, subscribeSettings } from './methods/getSettings'; import getRooms from './methods/getRooms'; import { setPermissions, getPermissions } from './methods/getPermissions'; @@ -883,6 +883,7 @@ const RocketChat = { getSettings, getLoginSettings, setSettings, + subscribeSettings, getPermissions, setPermissions, getCustomEmojis, diff --git a/app/sagas/login.js b/app/sagas/login.js index 83eb04dd..9381e045 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -80,6 +80,10 @@ const handleLoginRequest = function* handleLoginRequest({ credentials, logoutOnE } }; +const subscribeSettings = function* subscribeSettings() { + yield RocketChat.subscribeSettings(); +}; + const fetchPermissions = function* fetchPermissions() { yield RocketChat.getPermissions(); }; @@ -133,6 +137,7 @@ const handleLoginSuccess = function* handleLoginSuccess({ user }) { yield fork(registerPushToken); yield fork(fetchUsersPresence); yield fork(fetchEnterpriseModules, { user }); + yield fork(subscribeSettings); yield put(encryptionInit()); setLanguage(user?.language);