From 1c1dfe5af1dc7e7cc2846631607619cf9d92b8eb Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Wed, 20 Jul 2022 17:49:51 -0300 Subject: [PATCH] [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 --- app/sagas/login.js | 4 ++-- app/sagas/selectServer.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/sagas/login.js b/app/sagas/login.js index 28843515d..1a9318806 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -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) { diff --git a/app/sagas/selectServer.js b/app/sagas/selectServer.js index b6669db01..9e65fa7bf 100644 --- a/app/sagas/selectServer.js +++ b/app/sagas/selectServer.js @@ -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 });