Skip to content

Commit

Permalink
Removing ErrorStore. (mattermost#1976)
Browse files Browse the repository at this point in the history
  • Loading branch information
crspeller committed Nov 1, 2018
1 parent 5084127 commit 1c28a3d
Show file tree
Hide file tree
Showing 40 changed files with 667 additions and 810 deletions.
2 changes: 0 additions & 2 deletions actions/global_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import {getCurrentLocale} from 'selectors/i18n';
import {getIsRhsOpen, getRhsState} from 'selectors/rhs';
import BrowserStore from 'stores/browser_store.jsx';
import ErrorStore from 'stores/error_store.jsx';
import store from 'stores/redux_store.jsx';
import LocalStorageStore from 'stores/local_storage_store';
import WebSocketClient from 'client/web_websocket_client.jsx';
Expand Down Expand Up @@ -400,7 +399,6 @@ export function emitUserLoggedOutEvent(redirectTo = '/', shouldSignalLogout = tr
}

BrowserStore.clear();
ErrorStore.clearLastError();
stopPeriodicStatusUpdates();
WebsocketActions.close();
document.cookie = 'MMUSERID=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
Expand Down
20 changes: 20 additions & 0 deletions actions/views/system.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import {ActionTypes} from 'utils/constants.jsx';

export function incrementWsErrorCount() {
return async (dispatch) => {
dispatch({
type: ActionTypes.INCREMENT_WS_ERROR_COUNT,
});
};
}

export function resetWsErrorCount() {
return async (dispatch) => {
dispatch({
type: ActionTypes.RESET_WS_ERROR_COUNT,
});
};
}
19 changes: 9 additions & 10 deletions actions/websocket_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
markChannelAsRead,
} from 'mattermost-redux/actions/channels';
import {setServerVersion} from 'mattermost-redux/actions/general';
import {clearErrors, logError} from 'mattermost-redux/actions/errors';

import {getPosts, getProfilesAndStatusesForPosts, getCustomEmojiForReaction} from 'mattermost-redux/actions/posts';
import * as TeamActions from 'mattermost-redux/actions/teams';
import {getMe, getStatusesByIds, getProfilesByIds} from 'mattermost-redux/actions/users';
Expand All @@ -21,13 +23,14 @@ import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getChannel, getCurrentChannel, getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';

import {openModal} from 'actions/views/modals';
import {incrementWsErrorCount, resetWsErrorCount} from 'actions/views/system';

import {browserHistory} from 'utils/browser_history';
import {loadChannelsForCurrentUser} from 'actions/channel_actions.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import {handleNewPost} from 'actions/post_actions.jsx';
import * as StatusActions from 'actions/status_actions.jsx';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import ErrorStore from 'stores/error_store.jsx';
import store from 'stores/redux_store.jsx';
import WebSocketClient from 'client/web_websocket_client.jsx';
import {loadPlugin, loadPluginsIfNecessary, removePlugin} from 'plugins';
Expand Down Expand Up @@ -130,9 +133,8 @@ export function reconnect(includeWebSocket = true) {
dispatch(TeamActions.getMyTeamUnreads());
}

ErrorStore.setConnectionErrorCount(0);
ErrorStore.clearLastError();
ErrorStore.emitChange();
dispatch(resetWsErrorCount());
dispatch(clearErrors());
}

let intervalId = '';
Expand Down Expand Up @@ -176,17 +178,14 @@ export function unregisterAllPluginWebSocketEvents(pluginId) {
}

function handleFirstConnect() {
ErrorStore.clearLastError();
ErrorStore.emitChange();
dispatch(clearErrors);
}

function handleClose(failCount) {
if (failCount > MAX_WEBSOCKET_FAILS) {
ErrorStore.storeLastError({message: AnnouncementBarMessages.WEBSOCKET_PORT_ERROR});
dispatch(logError({type: 'critical', message: AnnouncementBarMessages.WEBSOCKET_PORT_ERROR}, true));
}

ErrorStore.setConnectionErrorCount(failCount);
ErrorStore.emitChange();
dispatch(incrementWsErrorCount());
}

function handleEvent(msg) {
Expand Down
8 changes: 0 additions & 8 deletions components/admin_console/email_settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import React from 'react';
import {FormattedHTMLMessage, FormattedMessage} from 'react-intl';

import ErrorStore from 'stores/error_store.jsx';
import {AnnouncementBarMessages} from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';

import EmailConnectionTest from 'components/admin_console/email_connection_test';
Expand Down Expand Up @@ -51,12 +49,6 @@ export default class EmailSettings extends AdminSettings {
return config;
}

handleSaved(newConfig) {
if (newConfig.EmailSettings.SendEmailNotifications || !newConfig.EmailSettings.EnablePreviewModeBanner) {
ErrorStore.clearError(AnnouncementBarMessages.PREVIEW_MODE);
}
}

getStateFromConfig(config) {
return {
sendEmailNotifications: config.EmailSettings.SendEmailNotifications,
Expand Down
9 changes: 2 additions & 7 deletions components/admin_console/jobs/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import React from 'react';
import {FormattedDate, FormattedMessage, FormattedTime, injectIntl, intlShape} from 'react-intl';

import {cancelJob, createJob} from 'actions/job_actions.jsx';
import ErrorStore from 'stores/error_store.jsx';
import {JobStatuses} from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';

Expand Down Expand Up @@ -276,9 +275,7 @@ class JobTable extends React.PureComponent {
() => {
this.reload();
},
(err) => {
ErrorStore.storeLastError(err);
ErrorStore.emitChange();
() => {
this.reload();
}
);
Expand All @@ -296,9 +293,7 @@ class JobTable extends React.PureComponent {
() => {
this.reload();
},
(err) => {
ErrorStore.storeLastError(err);
ErrorStore.emitChange();
() => {
this.reload();
}
);
Expand Down
2 changes: 0 additions & 2 deletions components/admin_console/license_settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ReactDOM from 'react-dom';
import {defineMessages, FormattedMessage, injectIntl, intlShape} from 'react-intl';

import {removeLicenseFile, uploadLicenseFile} from 'actions/admin_actions.jsx';
import ErrorStore from 'stores/error_store.jsx';
import * as Utils from 'utils/utils.jsx';
import {t} from 'utils/i18n';

Expand Down Expand Up @@ -83,7 +82,6 @@ class LicenseSettings extends React.Component {
() => {
$('#remove-button').button('reset');
this.setState({fileSelected: false, fileName: null, serverError: null});
ErrorStore.clearLastError(true);
window.location.reload(true);
},
(error) => {
Expand Down
Loading

0 comments on commit 1c28a3d

Please sign in to comment.