[FIX] Share Extension shows a server that has no user logged in (#4336)

* [FIX] Share Extension shows a server that has no user logged in

* set server after login
This commit is contained in:
Gleidson Daniel Silva 2022-07-20 17:49:51 -03:00 committed by Diego Mello
parent affa768728
commit 30af60cd58
2 changed files with 3 additions and 3 deletions

View File

@ -20,7 +20,7 @@ import { inquiryRequest, inquiryReset } from '../ee/omnichannel/actions/inquiry'
import { isOmnichannelStatusAvailable } from '../ee/omnichannel/lib';
import { RootEnum } from '../definitions';
import sdk from '../lib/services/sdk';
import { TOKEN_KEY } from '../lib/constants';
import { CURRENT_SERVER, TOKEN_KEY } from '../lib/constants';
import {
getCustomEmojis,
getEnterpriseModules,
@ -181,9 +181,9 @@ const handleLoginSuccess = function* handleLoginSuccess({ user }) {
UserPreferences.setString(`${TOKEN_KEY}-${server}`, user.id);
UserPreferences.setString(`${TOKEN_KEY}-${user.id}`, user.token);
UserPreferences.setString(CURRENT_SERVER, server);
yield put(setUser(user));
EventEmitter.emit('connected');
yield put(appStart({ root: RootEnum.ROOT_INSIDE }));
const inviteLinkToken = yield select(state => state.inviteLinks.token);
if (inviteLinkToken) {

View File

@ -78,7 +78,6 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch
yield put(encryptionStop());
yield put(clearActiveUsers());
const serversDB = database.servers;
UserPreferences.setString(CURRENT_SERVER, server);
const userId = UserPreferences.getString(`${TOKEN_KEY}-${server}`);
const userCollections = serversDB.get('users');
let user = null;
@ -117,6 +116,7 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch
yield put(setUser(user));
yield connect({ server, logoutOnError: true });
yield put(appStart({ root: RootEnum.ROOT_INSIDE }));
UserPreferences.setString(CURRENT_SERVER, server); // only set server after have a user
} else {
yield put(clearUser());
yield connect({ server });