mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Remove unused functions getPing and resetPing (#24065)
* Remove unused functions getPing and resetPing * Remove PING_RESET * Remove unused import lines * One more to go --------- Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
committed by
GitHub
parent
d1691833ad
commit
72b648cf81
@@ -4,8 +4,6 @@
|
||||
import keyMirror from 'mattermost-redux/utils/key_mirror';
|
||||
|
||||
export default keyMirror({
|
||||
PING_RESET: null,
|
||||
|
||||
RECEIVED_SERVER_VERSION: null,
|
||||
|
||||
CLIENT_CONFIG_RECEIVED: null,
|
||||
|
||||
@@ -10,10 +10,6 @@ import {Client4} from 'mattermost-redux/client';
|
||||
import TestHelper from '../../test/test_helper';
|
||||
import configureStore from '../../test/test_store';
|
||||
|
||||
import {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import {FormattedError} from './helpers';
|
||||
|
||||
const OK_RESPONSE = {status: 'OK'};
|
||||
|
||||
describe('Actions.General', () => {
|
||||
@@ -30,40 +26,6 @@ describe('Actions.General', () => {
|
||||
TestHelper.tearDown();
|
||||
});
|
||||
|
||||
it('getPing - Invalid URL', async () => {
|
||||
const serverUrl = Client4.getUrl();
|
||||
Client4.setUrl('notarealurl');
|
||||
|
||||
const pingError = new FormattedError(
|
||||
'mobile.server_ping_failed',
|
||||
'Cannot connect to the server. Please check your server URL and internet connection.',
|
||||
);
|
||||
|
||||
nock(Client4.getBaseRoute()).
|
||||
get('/system/ping').
|
||||
query(true).
|
||||
reply(401, {error: 'ping error', code: 401});
|
||||
|
||||
const {error} = await Actions.getPing()(store.dispatch, store.getState) as ActionResult;
|
||||
Client4.setUrl(serverUrl);
|
||||
expect(error).toEqual(pingError);
|
||||
});
|
||||
|
||||
it('getPing', async () => {
|
||||
const response = {
|
||||
status: 'OK',
|
||||
version: '4.0.0',
|
||||
};
|
||||
|
||||
nock(Client4.getBaseRoute()).
|
||||
get('/system/ping').
|
||||
query(true).
|
||||
reply(200, response);
|
||||
|
||||
const {data} = await Actions.getPing()(store.dispatch, store.getState) as ActionResult;
|
||||
expect(data).toEqual(response);
|
||||
});
|
||||
|
||||
it('getClientConfig', async () => {
|
||||
nock(Client4.getBaseRoute()).
|
||||
get('/config/client').
|
||||
|
||||
@@ -14,40 +14,7 @@ import {GetStateFunc, DispatchFunc, ActionFunc} from 'mattermost-redux/types/act
|
||||
|
||||
import {logError} from './errors';
|
||||
import {loadRolesIfNeeded} from './roles';
|
||||
import {bindClientFunc, forceLogoutIfNecessary, FormattedError} from './helpers';
|
||||
|
||||
export function getPing(): ActionFunc {
|
||||
return async () => {
|
||||
let data;
|
||||
let pingError = new FormattedError(
|
||||
'mobile.server_ping_failed',
|
||||
'Cannot connect to the server. Please check your server URL and internet connection.',
|
||||
);
|
||||
try {
|
||||
data = await Client4.ping();
|
||||
if (data.status !== 'OK') {
|
||||
// successful ping but not the right return {data}
|
||||
return {error: pingError};
|
||||
}
|
||||
} catch (error) { // ServerError
|
||||
if (error.status_code === 401) {
|
||||
// When the server requires a client certificate to connect.
|
||||
pingError = error;
|
||||
}
|
||||
return {error: pingError};
|
||||
}
|
||||
|
||||
return {data};
|
||||
};
|
||||
}
|
||||
|
||||
export function resetPing(): ActionFunc {
|
||||
return async (dispatch: DispatchFunc) => {
|
||||
dispatch({type: GeneralTypes.PING_RESET, data: {}});
|
||||
|
||||
return {data: true};
|
||||
};
|
||||
}
|
||||
import {bindClientFunc, forceLogoutIfNecessary} from './helpers';
|
||||
|
||||
export function getClientConfig(): ActionFunc {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
@@ -210,7 +177,6 @@ export function getFirstAdminSetupComplete(): ActionFunc {
|
||||
}
|
||||
|
||||
export default {
|
||||
getPing,
|
||||
getClientConfig,
|
||||
getDataRetentionPolicy,
|
||||
getLicenseConfig,
|
||||
|
||||
Reference in New Issue
Block a user