Fixing blue bar and renders warning when mis-configured.
Этот коммит содержится в:
@@ -3,9 +3,6 @@
|
|||||||
|
|
||||||
var ErrorStore = require('../stores/error_store.jsx');
|
var ErrorStore = require('../stores/error_store.jsx');
|
||||||
var utils = require('../utils/utils.jsx');
|
var utils = require('../utils/utils.jsx');
|
||||||
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
|
|
||||||
var Constants = require('../utils/constants.jsx');
|
|
||||||
var ActionTypes = Constants.ActionTypes;
|
|
||||||
|
|
||||||
export default class ErrorBar extends React.Component {
|
export default class ErrorBar extends React.Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -13,70 +10,79 @@ export default class ErrorBar extends React.Component {
|
|||||||
|
|
||||||
this.onErrorChange = this.onErrorChange.bind(this);
|
this.onErrorChange = this.onErrorChange.bind(this);
|
||||||
this.handleClose = this.handleClose.bind(this);
|
this.handleClose = this.handleClose.bind(this);
|
||||||
|
this.prevTimmer = null;
|
||||||
|
|
||||||
this.state = this.getStateFromStores();
|
this.state = ErrorStore.getLastError();
|
||||||
if (this.state.message) {
|
if (this.state && this.state.message) {
|
||||||
setTimeout(this.handleClose, 10000);
|
this.prevTimmer = setTimeout(this.handleClose, 10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getStateFromStores() {
|
|
||||||
var error = ErrorStore.getLastError();
|
|
||||||
if (!error || error.message === 'There appears to be a problem with your internet connection') {
|
|
||||||
return {message: null};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {message: error.message};
|
|
||||||
}
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
ErrorStore.addChangeListener(this.onErrorChange);
|
ErrorStore.addChangeListener(this.onErrorChange);
|
||||||
$('body').css('padding-top', $(React.findDOMNode(this)).outerHeight());
|
$('body').css('padding-top', $(React.findDOMNode(this)).outerHeight());
|
||||||
$(window).resize(function onResize() {
|
$(window).resize(() => {
|
||||||
if (this.state.message) {
|
if (this.state && this.state.message) {
|
||||||
$('body').css('padding-top', $(React.findDOMNode(this)).outerHeight());
|
$('body').css('padding-top', $(React.findDOMNode(this)).outerHeight());
|
||||||
}
|
}
|
||||||
}.bind(this));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
ErrorStore.removeChangeListener(this.onErrorChange);
|
ErrorStore.removeChangeListener(this.onErrorChange);
|
||||||
}
|
}
|
||||||
onErrorChange() {
|
|
||||||
var newState = this.getStateFromStores();
|
|
||||||
if (!utils.areStatesEqual(newState, this.state)) {
|
|
||||||
if (newState.message) {
|
|
||||||
setTimeout(this.handleClose, 10000);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
onErrorChange() {
|
||||||
|
var newState = ErrorStore.getLastError();
|
||||||
|
|
||||||
|
if (this.prevTimmer != null) {
|
||||||
|
clearInterval(this.prevTimmer);
|
||||||
|
this.prevTimmer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newState) {
|
||||||
this.setState(newState);
|
this.setState(newState);
|
||||||
|
this.prevTimmer = setTimeout(this.handleClose, 10000);
|
||||||
|
} else {
|
||||||
|
this.setState({message: null});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClose(e) {
|
handleClose(e) {
|
||||||
if (e) {
|
if (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
AppDispatcher.handleServerAction({
|
ErrorStore.storeLastError(null);
|
||||||
type: ActionTypes.RECIEVED_ERROR,
|
ErrorStore.emitChange();
|
||||||
err: null
|
|
||||||
});
|
|
||||||
|
|
||||||
$('body').css('padding-top', '0');
|
$('body').css('padding-top', '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.state.message) {
|
if (!this.state) {
|
||||||
return (
|
return <div/>;
|
||||||
<div className='error-bar'>
|
|
||||||
<span>{this.state.message}</span>
|
|
||||||
<a
|
|
||||||
href='#'
|
|
||||||
className='error-bar__close'
|
|
||||||
onClick={this.handleClose}
|
|
||||||
>
|
|
||||||
×
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return <div/>;
|
if (!this.state.message) {
|
||||||
|
return <div/>;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state.connErrorCount < 7) {
|
||||||
|
return <div/>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='error-bar'>
|
||||||
|
<span>{this.state.message}</span>
|
||||||
|
<a
|
||||||
|
href='#'
|
||||||
|
className='error-bar__close'
|
||||||
|
onClick={this.handleClose}
|
||||||
|
>
|
||||||
|
×
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ const AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
|
|||||||
const PostStore = require('../stores/post_store.jsx');
|
const PostStore = require('../stores/post_store.jsx');
|
||||||
const CommandList = require('./command_list.jsx');
|
const CommandList = require('./command_list.jsx');
|
||||||
const ErrorStore = require('../stores/error_store.jsx');
|
const ErrorStore = require('../stores/error_store.jsx');
|
||||||
const AsyncClient = require('../utils/async_client.jsx');
|
|
||||||
|
|
||||||
const Utils = require('../utils/utils.jsx');
|
const Utils = require('../utils/utils.jsx');
|
||||||
const Constants = require('../utils/constants.jsx');
|
const Constants = require('../utils/constants.jsx');
|
||||||
@@ -18,7 +17,6 @@ export default class Textbox extends React.Component {
|
|||||||
this.getStateFromStores = this.getStateFromStores.bind(this);
|
this.getStateFromStores = this.getStateFromStores.bind(this);
|
||||||
this.onListenerChange = this.onListenerChange.bind(this);
|
this.onListenerChange = this.onListenerChange.bind(this);
|
||||||
this.onRecievedError = this.onRecievedError.bind(this);
|
this.onRecievedError = this.onRecievedError.bind(this);
|
||||||
this.onTimerInterrupt = this.onTimerInterrupt.bind(this);
|
|
||||||
this.updateMentionTab = this.updateMentionTab.bind(this);
|
this.updateMentionTab = this.updateMentionTab.bind(this);
|
||||||
this.handleChange = this.handleChange.bind(this);
|
this.handleChange = this.handleChange.bind(this);
|
||||||
this.handleKeyPress = this.handleKeyPress.bind(this);
|
this.handleKeyPress = this.handleKeyPress.bind(this);
|
||||||
@@ -35,8 +33,7 @@ export default class Textbox extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
mentionText: '-1',
|
mentionText: '-1',
|
||||||
mentions: [],
|
mentions: [],
|
||||||
connection: '',
|
connection: ''
|
||||||
timerInterrupt: null
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.caret = -1;
|
this.caret = -1;
|
||||||
@@ -44,6 +41,7 @@ export default class Textbox extends React.Component {
|
|||||||
this.doProcessMentions = false;
|
this.doProcessMentions = false;
|
||||||
this.mentions = [];
|
this.mentions = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
getStateFromStores() {
|
getStateFromStores() {
|
||||||
const error = ErrorStore.getLastError();
|
const error = ErrorStore.getLastError();
|
||||||
|
|
||||||
@@ -53,6 +51,7 @@ export default class Textbox extends React.Component {
|
|||||||
|
|
||||||
return {message: null};
|
return {message: null};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
PostStore.addAddMentionListener(this.onListenerChange);
|
PostStore.addAddMentionListener(this.onListenerChange);
|
||||||
ErrorStore.addChangeListener(this.onRecievedError);
|
ErrorStore.addChangeListener(this.onRecievedError);
|
||||||
@@ -60,46 +59,28 @@ export default class Textbox extends React.Component {
|
|||||||
this.resize();
|
this.resize();
|
||||||
this.updateMentionTab(null);
|
this.updateMentionTab(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
PostStore.removeAddMentionListener(this.onListenerChange);
|
PostStore.removeAddMentionListener(this.onListenerChange);
|
||||||
ErrorStore.removeChangeListener(this.onRecievedError);
|
ErrorStore.removeChangeListener(this.onRecievedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
onListenerChange(id, username) {
|
onListenerChange(id, username) {
|
||||||
if (id === this.props.id) {
|
if (id === this.props.id) {
|
||||||
this.addMention(username);
|
this.addMention(username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onRecievedError() {
|
onRecievedError() {
|
||||||
const errorState = this.getStateFromStores();
|
const errorState = ErrorStore.getLastError();
|
||||||
|
|
||||||
if (this.state.timerInterrupt !== null) {
|
if (errorState && errorState.connErrorCount > 0) {
|
||||||
window.clearInterval(this.state.timerInterrupt);
|
|
||||||
this.setState({timerInterrupt: null});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errorState.message === 'There appears to be a problem with your internet connection') {
|
|
||||||
this.setState({connection: 'bad-connection'});
|
this.setState({connection: 'bad-connection'});
|
||||||
const timerInterrupt = window.setInterval(this.onTimerInterrupt, 5000);
|
|
||||||
this.setState({timerInterrupt: timerInterrupt});
|
|
||||||
} else {
|
} else {
|
||||||
this.setState({connection: ''});
|
this.setState({connection: ''});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onTimerInterrupt() {
|
|
||||||
// Since these should only happen when you have no connection and slightly briefly after any
|
|
||||||
// performance hit should not matter
|
|
||||||
if (this.state.connection === 'bad-connection') {
|
|
||||||
AppDispatcher.handleServerAction({
|
|
||||||
type: ActionTypes.RECIEVED_ERROR,
|
|
||||||
err: null
|
|
||||||
});
|
|
||||||
|
|
||||||
AsyncClient.updateLastViewedAt();
|
|
||||||
}
|
|
||||||
|
|
||||||
window.clearInterval(this.state.timerInterrupt);
|
|
||||||
this.setState({timerInterrupt: null});
|
|
||||||
}
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
if (this.caret >= 0) {
|
if (this.caret >= 0) {
|
||||||
Utils.setCaretPosition(React.findDOMNode(this.refs.message), this.caret);
|
Utils.setCaretPosition(React.findDOMNode(this.refs.message), this.caret);
|
||||||
@@ -111,6 +92,7 @@ export default class Textbox extends React.Component {
|
|||||||
}
|
}
|
||||||
this.resize();
|
this.resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
if (!this.addedMention) {
|
if (!this.addedMention) {
|
||||||
this.checkForNewMention(nextProps.messageText);
|
this.checkForNewMention(nextProps.messageText);
|
||||||
@@ -122,19 +104,22 @@ export default class Textbox extends React.Component {
|
|||||||
this.addedMention = false;
|
this.addedMention = false;
|
||||||
this.refs.commands.getSuggestedCommands(nextProps.messageText);
|
this.refs.commands.getSuggestedCommands(nextProps.messageText);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMentionTab(mentionText) {
|
updateMentionTab(mentionText) {
|
||||||
// using setTimeout so dispatch isn't called during an in progress dispatch
|
// using setTimeout so dispatch isn't called during an in progress dispatch
|
||||||
setTimeout(function updateMentionTabAfterTimeout() {
|
setTimeout(() => {
|
||||||
AppDispatcher.handleViewAction({
|
AppDispatcher.handleViewAction({
|
||||||
type: ActionTypes.RECIEVED_MENTION_DATA,
|
type: ActionTypes.RECIEVED_MENTION_DATA,
|
||||||
id: this.props.id,
|
id: this.props.id,
|
||||||
mention_text: mentionText
|
mention_text: mentionText
|
||||||
});
|
});
|
||||||
}.bind(this), 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChange() {
|
handleChange() {
|
||||||
this.props.onUserInput(React.findDOMNode(this.refs.message).value);
|
this.props.onUserInput(React.findDOMNode(this.refs.message).value);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleKeyPress(e) {
|
handleKeyPress(e) {
|
||||||
const text = React.findDOMNode(this.refs.message).value;
|
const text = React.findDOMNode(this.refs.message).value;
|
||||||
|
|
||||||
@@ -157,6 +142,7 @@ export default class Textbox extends React.Component {
|
|||||||
|
|
||||||
this.props.onKeyPress(e);
|
this.props.onKeyPress(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleKeyDown(e) {
|
handleKeyDown(e) {
|
||||||
if (Utils.getSelectedText(React.findDOMNode(this.refs.message)) !== '') {
|
if (Utils.getSelectedText(React.findDOMNode(this.refs.message)) !== '') {
|
||||||
this.doProcessMentions = true;
|
this.doProcessMentions = true;
|
||||||
@@ -166,6 +152,7 @@ export default class Textbox extends React.Component {
|
|||||||
this.handleBackspace(e);
|
this.handleBackspace(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleBackspace() {
|
handleBackspace() {
|
||||||
const text = React.findDOMNode(this.refs.message).value;
|
const text = React.findDOMNode(this.refs.message).value;
|
||||||
if (text.indexOf('/') === 0) {
|
if (text.indexOf('/') === 0) {
|
||||||
@@ -185,6 +172,7 @@ export default class Textbox extends React.Component {
|
|||||||
this.doProcessMentions = true;
|
this.doProcessMentions = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkForNewMention(text) {
|
checkForNewMention(text) {
|
||||||
const caret = Utils.getCaretPosition(React.findDOMNode(this.refs.message));
|
const caret = Utils.getCaretPosition(React.findDOMNode(this.refs.message));
|
||||||
|
|
||||||
@@ -211,6 +199,7 @@ export default class Textbox extends React.Component {
|
|||||||
const name = preText.substring(atIndex + 1, preText.length).toLowerCase();
|
const name = preText.substring(atIndex + 1, preText.length).toLowerCase();
|
||||||
this.updateMentionTab(name);
|
this.updateMentionTab(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
addMention(name) {
|
addMention(name) {
|
||||||
const caret = Utils.getCaretPosition(React.findDOMNode(this.refs.message));
|
const caret = Utils.getCaretPosition(React.findDOMNode(this.refs.message));
|
||||||
|
|
||||||
@@ -233,11 +222,13 @@ export default class Textbox extends React.Component {
|
|||||||
|
|
||||||
this.props.onUserInput(`${prefix}@${name} ${suffix}`);
|
this.props.onUserInput(`${prefix}@${name} ${suffix}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
addCommand(cmd) {
|
addCommand(cmd) {
|
||||||
const elm = React.findDOMNode(this.refs.message);
|
const elm = React.findDOMNode(this.refs.message);
|
||||||
elm.value = cmd;
|
elm.value = cmd;
|
||||||
this.handleChange();
|
this.handleChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
resize() {
|
resize() {
|
||||||
const e = React.findDOMNode(this.refs.message);
|
const e = React.findDOMNode(this.refs.message);
|
||||||
const w = React.findDOMNode(this.refs.wrapper);
|
const w = React.findDOMNode(this.refs.wrapper);
|
||||||
@@ -264,21 +255,25 @@ export default class Textbox extends React.Component {
|
|||||||
this.props.onHeightChange();
|
this.props.onHeightChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleFocus() {
|
handleFocus() {
|
||||||
const elm = React.findDOMNode(this.refs.message);
|
const elm = React.findDOMNode(this.refs.message);
|
||||||
if (elm.title === elm.value) {
|
if (elm.title === elm.value) {
|
||||||
elm.value = '';
|
elm.value = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleBlur() {
|
handleBlur() {
|
||||||
const elm = React.findDOMNode(this.refs.message);
|
const elm = React.findDOMNode(this.refs.message);
|
||||||
if (elm.value === '') {
|
if (elm.value === '') {
|
||||||
elm.value = elm.title;
|
elm.value = elm.title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePaste() {
|
handlePaste() {
|
||||||
this.doProcessMentions = true;
|
this.doProcessMentions = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ var ChannelInviteModal = require('../components/channel_invite_modal.jsx');
|
|||||||
var TeamMembersModal = require('../components/team_members.jsx');
|
var TeamMembersModal = require('../components/team_members.jsx');
|
||||||
var DirectChannelModal = require('../components/more_direct_channels.jsx');
|
var DirectChannelModal = require('../components/more_direct_channels.jsx');
|
||||||
var ErrorBar = require('../components/error_bar.jsx');
|
var ErrorBar = require('../components/error_bar.jsx');
|
||||||
|
var ErrorStore = require('../stores/error_store.jsx');
|
||||||
var ChannelLoader = require('../components/channel_loader.jsx');
|
var ChannelLoader = require('../components/channel_loader.jsx');
|
||||||
var MentionList = require('../components/mention_list.jsx');
|
var MentionList = require('../components/mention_list.jsx');
|
||||||
var ChannelInfoModal = require('../components/channel_info_modal.jsx');
|
var ChannelInfoModal = require('../components/channel_info_modal.jsx');
|
||||||
@@ -234,6 +235,11 @@ function setupChannelPage(props) {
|
|||||||
<RegisterAppModal />,
|
<RegisterAppModal />,
|
||||||
document.getElementById('register_app_modal')
|
document.getElementById('register_app_modal')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (global.window.config.SendEmailNotifications === 'false') {
|
||||||
|
ErrorStore.storeLastError({message: 'Preview Mode: Email notifications have not been configured'});
|
||||||
|
ErrorStore.emitChange();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
global.window.setup_channel_page = setupChannelPage;
|
global.window.setup_channel_page = setupChannelPage;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class ErrorStoreClass extends EventEmitter {
|
|||||||
|
|
||||||
var ErrorStore = new ErrorStoreClass();
|
var ErrorStore = new ErrorStoreClass();
|
||||||
|
|
||||||
ErrorStore.dispatchToken = AppDispatcher.register(function registry(payload) {
|
ErrorStore.dispatchToken = AppDispatcher.register((payload) => {
|
||||||
var action = payload.action;
|
var action = payload.action;
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ActionTypes.RECIEVED_ERROR:
|
case ActionTypes.RECIEVED_ERROR:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
|
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
|
||||||
var UserStore = require('./user_store.jsx');
|
var UserStore = require('./user_store.jsx');
|
||||||
|
var ErrorStore = require('./error_store.jsx');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
var Constants = require('../utils/constants.jsx');
|
var Constants = require('../utils/constants.jsx');
|
||||||
@@ -21,6 +22,7 @@ class SocketStoreClass extends EventEmitter {
|
|||||||
this.addChangeListener = this.addChangeListener.bind(this);
|
this.addChangeListener = this.addChangeListener.bind(this);
|
||||||
this.removeChangeListener = this.removeChangeListener.bind(this);
|
this.removeChangeListener = this.removeChangeListener.bind(this);
|
||||||
this.sendMessage = this.sendMessage.bind(this);
|
this.sendMessage = this.sendMessage.bind(this);
|
||||||
|
this.failCount = 0;
|
||||||
|
|
||||||
this.initialize();
|
this.initialize();
|
||||||
}
|
}
|
||||||
@@ -37,27 +39,43 @@ class SocketStoreClass extends EventEmitter {
|
|||||||
protocol = 'wss://';
|
protocol = 'wss://';
|
||||||
}
|
}
|
||||||
var connUrl = protocol + location.host + '/api/v1/websocket';
|
var connUrl = protocol + location.host + '/api/v1/websocket';
|
||||||
console.log('connecting to ' + connUrl); //eslint-disable-line no-console
|
if (this.failCount === 0) {
|
||||||
|
console.log('websocket connecting to ' + connUrl); //eslint-disable-line no-console
|
||||||
|
}
|
||||||
conn = new WebSocket(connUrl);
|
conn = new WebSocket(connUrl);
|
||||||
|
|
||||||
conn.onclose = function closeConn(evt) {
|
conn.onopen = () => {
|
||||||
console.log('websocket closed'); //eslint-disable-line no-console
|
if (this.failCount > 0) {
|
||||||
console.log(evt); //eslint-disable-line no-console
|
console.log('websocket re-established connection'); //eslint-disable-line no-console
|
||||||
conn = null;
|
}
|
||||||
setTimeout(
|
|
||||||
function reconnect() {
|
|
||||||
this.initialize();
|
|
||||||
}.bind(this),
|
|
||||||
3000
|
|
||||||
);
|
|
||||||
}.bind(this);
|
|
||||||
|
|
||||||
conn.onerror = function connError(evt) {
|
this.failCount = 0;
|
||||||
console.log('websocket error'); //eslint-disable-line no-console
|
ErrorStore.storeLastError(null);
|
||||||
console.log(evt); //eslint-disable-line no-console
|
ErrorStore.emitChange();
|
||||||
};
|
};
|
||||||
|
|
||||||
conn.onmessage = function connMessage(evt) {
|
conn.onclose = () => {
|
||||||
|
conn = null;
|
||||||
|
setTimeout(
|
||||||
|
() => {
|
||||||
|
this.initialize();
|
||||||
|
},
|
||||||
|
3000
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
conn.onerror = (evt) => {
|
||||||
|
if (this.failCount === 0) {
|
||||||
|
console.log('websocket error ' + evt); //eslint-disable-line no-console
|
||||||
|
}
|
||||||
|
|
||||||
|
this.failCount = this.failCount + 1;
|
||||||
|
|
||||||
|
ErrorStore.storeLastError({connErrorCount: this.failCount, message: 'We cannot reach the Mattermost service. The service may be down or misconfigured. Please contact an administrator to make sure the WebSocket port is configured properly.'});
|
||||||
|
ErrorStore.emitChange();
|
||||||
|
};
|
||||||
|
|
||||||
|
conn.onmessage = (evt) => {
|
||||||
AppDispatcher.handleServerAction({
|
AppDispatcher.handleServerAction({
|
||||||
type: ActionTypes.RECIEVED_MSG,
|
type: ActionTypes.RECIEVED_MSG,
|
||||||
msg: JSON.parse(evt.data)
|
msg: JSON.parse(evt.data)
|
||||||
@@ -86,7 +104,7 @@ class SocketStoreClass extends EventEmitter {
|
|||||||
|
|
||||||
var SocketStore = new SocketStoreClass();
|
var SocketStore = new SocketStoreClass();
|
||||||
|
|
||||||
SocketStore.dispatchToken = AppDispatcher.register(function registry(payload) {
|
SocketStore.dispatchToken = AppDispatcher.register((payload) => {
|
||||||
var action = payload.action;
|
var action = payload.action;
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ function handleError(methodName, xhr, status, err) {
|
|||||||
msg = 'error in ' + methodName + ' status=' + status + ' statusCode=' + xhr.status + ' err=' + err;
|
msg = 'error in ' + methodName + ' status=' + status + ' statusCode=' + xhr.status + ' err=' + err;
|
||||||
|
|
||||||
if (xhr.status === 0) {
|
if (xhr.status === 0) {
|
||||||
e = {message: 'There appears to be a problem with your internet connection'};
|
e = {message: 'There appears to be a problem with your internet connection', connErrorCount: 1};
|
||||||
} else {
|
} else {
|
||||||
e = {message: 'We received an unexpected status code from the server (' + xhr.status + ')'};
|
e = {message: 'We received an unexpected status code from the server (' + xhr.status + ')'};
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user