Skip to content

Commit

Permalink
[FIX] Subscribe to settings making app to hang on login (#3254)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello authored Jul 6, 2021
1 parent 999f05b commit 6385dae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/lib/methods/getSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion app/lib/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -883,6 +883,7 @@ const RocketChat = {
getSettings,
getLoginSettings,
setSettings,
subscribeSettings,
getPermissions,
setPermissions,
getCustomEmojis,
Expand Down
5 changes: 5 additions & 0 deletions app/sagas/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ const handleLoginRequest = function* handleLoginRequest({ credentials, logoutOnE
}
};

const subscribeSettings = function* subscribeSettings() {
yield RocketChat.subscribeSettings();
};

const fetchPermissions = function* fetchPermissions() {
yield RocketChat.getPermissions();
};
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6385dae

Please sign in to comment.