+ client: add isVersionGreater helper
This commit is contained in:
parent
0a26ee4224
commit
59a635f3f2
|
@ -2,8 +2,7 @@ import { createAction } from 'redux-actions';
|
||||||
import { t } from 'i18next';
|
import { t } from 'i18next';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import versionCompare from '../helpers/versionCompare';
|
import { normalizeTextarea, sortClients, isVersionGreater } from '../helpers/helpers';
|
||||||
import { normalizeTextarea, sortClients } from '../helpers/helpers';
|
|
||||||
import { SETTINGS_NAMES, CHECK_TIMEOUT } from '../helpers/constants';
|
import { SETTINGS_NAMES, CHECK_TIMEOUT } from '../helpers/constants';
|
||||||
import { getTlsStatus } from './encryption';
|
import { getTlsStatus } from './encryption';
|
||||||
import apiClient from '../api/Api';
|
import apiClient from '../api/Api';
|
||||||
|
@ -125,7 +124,7 @@ export const getVersion = (recheck = false) => async (dispatch, getState) => {
|
||||||
const { dnsVersion } = getState().dashboard;
|
const { dnsVersion } = getState().dashboard;
|
||||||
const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion;
|
const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion;
|
||||||
|
|
||||||
if (data && versionCompare(currentVersion, data.new_version) === -1) {
|
if (data && isVersionGreater(currentVersion, data.new_version)) {
|
||||||
dispatch(addSuccessToast('updates_checked'));
|
dispatch(addSuccessToast('updates_checked'));
|
||||||
} else {
|
} else {
|
||||||
dispatch(addSuccessToast('updates_version_equal'));
|
dispatch(addSuccessToast('updates_version_equal'));
|
||||||
|
|
|
@ -7,6 +7,7 @@ import subDays from 'date-fns/sub_days';
|
||||||
import round from 'lodash/round';
|
import round from 'lodash/round';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
||||||
|
import versionCompare from './versionCompare';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
STANDARD_DNS_PORT,
|
STANDARD_DNS_PORT,
|
||||||
|
@ -279,3 +280,7 @@ export const secondsToMilliseconds = (seconds) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const normalizeRulesTextarea = text => text && text.replace(/^\n/g, '').replace(/\n\s*\n/g, '\n');
|
export const normalizeRulesTextarea = text => text && text.replace(/^\n/g, '').replace(/\n\s*\n/g, '\n');
|
||||||
|
|
||||||
|
export const isVersionGreater = (currentVersion, previousVersion) => (
|
||||||
|
versionCompare(currentVersion, previousVersion) === -1
|
||||||
|
);
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { combineReducers } from 'redux';
|
||||||
import { handleActions } from 'redux-actions';
|
import { handleActions } from 'redux-actions';
|
||||||
import { loadingBarReducer } from 'react-redux-loading-bar';
|
import { loadingBarReducer } from 'react-redux-loading-bar';
|
||||||
import { reducer as formReducer } from 'redux-form';
|
import { reducer as formReducer } from 'redux-form';
|
||||||
import versionCompare from '../helpers/versionCompare';
|
import { isVersionGreater } from '../helpers/helpers';
|
||||||
|
|
||||||
import * as actions from '../actions';
|
import * as actions from '../actions';
|
||||||
import toasts from './toasts';
|
import toasts from './toasts';
|
||||||
|
@ -108,7 +108,7 @@ const dashboard = handleActions(
|
||||||
[actions.getVersionSuccess]: (state, { payload }) => {
|
[actions.getVersionSuccess]: (state, { payload }) => {
|
||||||
const currentVersion = state.dnsVersion === 'undefined' ? 0 : state.dnsVersion;
|
const currentVersion = state.dnsVersion === 'undefined' ? 0 : state.dnsVersion;
|
||||||
|
|
||||||
if (payload && versionCompare(currentVersion, payload.new_version) === -1) {
|
if (payload && isVersionGreater(currentVersion, payload.new_version)) {
|
||||||
const {
|
const {
|
||||||
announcement_url: announcementUrl,
|
announcement_url: announcementUrl,
|
||||||
new_version: newVersion,
|
new_version: newVersion,
|
||||||
|
|
Loading…
Reference in New Issue