Skip to content

Commit

Permalink
[FIX] Share Extension shows a server that has no user logged in (Rock…
Browse files Browse the repository at this point in the history
…etChat#4336)

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

* set server after login
  • Loading branch information
dnlsilva authored Jul 20, 2022
1 parent 4706fec commit 253d900
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/sagas/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion app/sagas/selectServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 });
Expand Down

0 comments on commit 253d900

Please sign in to comment.