Refresh login page if server version of client doesn't match browser version of client (#3004)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
2ccf5bbaa2
Коммит
34780f3aea
@@ -9,6 +9,7 @@ import * as GlobalActions from 'action_creators/global_actions.jsx';
|
|||||||
import UserStore from 'stores/user_store.jsx';
|
import UserStore from 'stores/user_store.jsx';
|
||||||
|
|
||||||
import Client from 'utils/web_client.jsx';
|
import Client from 'utils/web_client.jsx';
|
||||||
|
import * as AsyncClient from 'utils/async_client.jsx';
|
||||||
import * as TextFormatting from 'utils/text_formatting.jsx';
|
import * as TextFormatting from 'utils/text_formatting.jsx';
|
||||||
|
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
@@ -44,6 +45,8 @@ export default class Login extends React.Component {
|
|||||||
if (UserStore.getCurrentUser()) {
|
if (UserStore.getCurrentUser()) {
|
||||||
browserHistory.push('/select_team');
|
browserHistory.push('/select_team');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AsyncClient.checkVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
preSubmit(e) {
|
preSubmit(e) {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import * as AsyncClient from 'utils/async_client.jsx';
|
|||||||
import ChannelStore from 'stores/channel_store.jsx';
|
import ChannelStore from 'stores/channel_store.jsx';
|
||||||
import ErrorStore from 'stores/error_store.jsx';
|
import ErrorStore from 'stores/error_store.jsx';
|
||||||
import TeamStore from 'stores/team_store.jsx';
|
import TeamStore from 'stores/team_store.jsx';
|
||||||
|
import BrowserStore from 'stores/browser_store.jsx';
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
|
|
||||||
import Client from 'utils/web_client.jsx';
|
import Client from 'utils/web_client.jsx';
|
||||||
@@ -101,9 +102,10 @@ function preRenderSetup(callwhendone) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Make sure the websockets close
|
// Make sure the websockets close and reset version
|
||||||
$(window).on('beforeunload',
|
$(window).on('beforeunload',
|
||||||
() => {
|
() => {
|
||||||
|
BrowserStore.setLastServerVersion('');
|
||||||
Websockets.close();
|
Websockets.close();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ class BrowserStoreClass {
|
|||||||
clear() {
|
clear() {
|
||||||
// don't clear the logout id so IE11 can tell which tab sent a logout request
|
// don't clear the logout id so IE11 can tell which tab sent a logout request
|
||||||
const logoutId = sessionStorage.getItem('__logout__');
|
const logoutId = sessionStorage.getItem('__logout__');
|
||||||
|
const serverVersion = this.getLastServerVersion();
|
||||||
|
|
||||||
sessionStorage.clear();
|
sessionStorage.clear();
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
@@ -165,6 +166,10 @@ class BrowserStoreClass {
|
|||||||
if (logoutId) {
|
if (logoutId) {
|
||||||
sessionStorage.setItem('__logout__', logoutId);
|
sessionStorage.setItem('__logout__', logoutId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (serverVersion) {
|
||||||
|
this.setLastServerVersion(serverVersion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAll() {
|
clearAll() {
|
||||||
|
|||||||
@@ -47,7 +47,21 @@ function isCallInProgress(callName) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getChannels(checkVersion) {
|
export function checkVersion() {
|
||||||
|
var serverVersion = Client.getServerVersion();
|
||||||
|
|
||||||
|
if (serverVersion !== BrowserStore.getLastServerVersion()) {
|
||||||
|
if (!BrowserStore.getLastServerVersion() || BrowserStore.getLastServerVersion() === '') {
|
||||||
|
BrowserStore.setLastServerVersion(serverVersion);
|
||||||
|
} else {
|
||||||
|
BrowserStore.setLastServerVersion(serverVersion);
|
||||||
|
window.location.reload(true);
|
||||||
|
console.log('Detected version update refreshing the page'); //eslint-disable-line no-console
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getChannels(doVersionCheck) {
|
||||||
if (isCallInProgress('getChannels')) {
|
if (isCallInProgress('getChannels')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -58,18 +72,8 @@ export function getChannels(checkVersion) {
|
|||||||
(data) => {
|
(data) => {
|
||||||
callTracker.getChannels = 0;
|
callTracker.getChannels = 0;
|
||||||
|
|
||||||
if (checkVersion) {
|
if (doVersionCheck) {
|
||||||
var serverVersion = Client.getServerVersion();
|
checkVersion();
|
||||||
|
|
||||||
if (serverVersion !== BrowserStore.getLastServerVersion()) {
|
|
||||||
if (!BrowserStore.getLastServerVersion() || BrowserStore.getLastServerVersion() === '') {
|
|
||||||
BrowserStore.setLastServerVersion(serverVersion);
|
|
||||||
} else {
|
|
||||||
BrowserStore.setLastServerVersion(serverVersion);
|
|
||||||
window.location.reload(true);
|
|
||||||
console.log('Detected version update refreshing the page'); //eslint-disable-line no-console
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppDispatcher.handleServerAction({
|
AppDispatcher.handleServerAction({
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user