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>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d1691833ad
Коммит
72b648cf81
@@ -4,8 +4,6 @@
|
|||||||
import keyMirror from 'mattermost-redux/utils/key_mirror';
|
import keyMirror from 'mattermost-redux/utils/key_mirror';
|
||||||
|
|
||||||
export default keyMirror({
|
export default keyMirror({
|
||||||
PING_RESET: null,
|
|
||||||
|
|
||||||
RECEIVED_SERVER_VERSION: null,
|
RECEIVED_SERVER_VERSION: null,
|
||||||
|
|
||||||
CLIENT_CONFIG_RECEIVED: null,
|
CLIENT_CONFIG_RECEIVED: null,
|
||||||
|
|||||||
@@ -10,10 +10,6 @@ import {Client4} from 'mattermost-redux/client';
|
|||||||
import TestHelper from '../../test/test_helper';
|
import TestHelper from '../../test/test_helper';
|
||||||
import configureStore from '../../test/test_store';
|
import configureStore from '../../test/test_store';
|
||||||
|
|
||||||
import {ActionResult} from 'mattermost-redux/types/actions';
|
|
||||||
|
|
||||||
import {FormattedError} from './helpers';
|
|
||||||
|
|
||||||
const OK_RESPONSE = {status: 'OK'};
|
const OK_RESPONSE = {status: 'OK'};
|
||||||
|
|
||||||
describe('Actions.General', () => {
|
describe('Actions.General', () => {
|
||||||
@@ -30,40 +26,6 @@ describe('Actions.General', () => {
|
|||||||
TestHelper.tearDown();
|
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 () => {
|
it('getClientConfig', async () => {
|
||||||
nock(Client4.getBaseRoute()).
|
nock(Client4.getBaseRoute()).
|
||||||
get('/config/client').
|
get('/config/client').
|
||||||
|
|||||||
@@ -14,40 +14,7 @@ import {GetStateFunc, DispatchFunc, ActionFunc} from 'mattermost-redux/types/act
|
|||||||
|
|
||||||
import {logError} from './errors';
|
import {logError} from './errors';
|
||||||
import {loadRolesIfNeeded} from './roles';
|
import {loadRolesIfNeeded} from './roles';
|
||||||
import {bindClientFunc, forceLogoutIfNecessary, FormattedError} from './helpers';
|
import {bindClientFunc, forceLogoutIfNecessary} 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};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getClientConfig(): ActionFunc {
|
export function getClientConfig(): ActionFunc {
|
||||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||||
@@ -210,7 +177,6 @@ export function getFirstAdminSetupComplete(): ActionFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getPing,
|
|
||||||
getClientConfig,
|
getClientConfig,
|
||||||
getDataRetentionPolicy,
|
getDataRetentionPolicy,
|
||||||
getLicenseConfig,
|
getLicenseConfig,
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user