* (ui): fix the version check - strip the v prefix
This commit is contained in:
parent
4f4a688ee6
commit
1e5419714d
2
Makefile
2
Makefile
|
@ -196,7 +196,7 @@ define write_version_file
|
|||
echo " \"version\": \"$(version)\"," >> $(DIST_DIR)/version.json
|
||||
echo " \"announcement\": \"AdGuard Home $(version) is now available!\"," >> $(DIST_DIR)/version.json
|
||||
echo " \"announcement_url\": \"https://github.com/AdguardTeam/AdGuardHome/releases\"," >> $(DIST_DIR)/version.json
|
||||
echo " \"selfupdate_min_version\": \"v0.0\"," >> $(DIST_DIR)/version.json
|
||||
echo " \"selfupdate_min_version\": \"0.0\"," >> $(DIST_DIR)/version.json
|
||||
|
||||
# Windows builds
|
||||
echo " \"download_windows_amd64\": \"$(BASE_URL)/AdGuardHome_windows_amd64.zip\"," >> $(DIST_DIR)/version.json
|
||||
|
|
|
@ -12,7 +12,7 @@ module.exports = {
|
|||
"scope",
|
||||
"subject",
|
||||
"body",
|
||||
"issues"
|
||||
"issues",
|
||||
],
|
||||
"scopes": [
|
||||
"",
|
||||
|
|
|
@ -4,6 +4,7 @@ import axios from 'axios';
|
|||
|
||||
import { splitByNewLine, sortClients } from '../helpers/helpers';
|
||||
import { CHECK_TIMEOUT, SETTINGS_NAMES } from '../helpers/constants';
|
||||
import { areEqualVersions } from '../helpers/version';
|
||||
import { getTlsStatus } from './encryption';
|
||||
import apiClient from '../api/Api';
|
||||
import { addErrorToast, addNoticeToast, addSuccessToast } from './toasts';
|
||||
|
@ -121,7 +122,7 @@ export const getVersion = (recheck = false) => async (dispatch, getState) => {
|
|||
const { dnsVersion } = getState().dashboard;
|
||||
const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion;
|
||||
|
||||
if (data && currentVersion !== data.new_version) {
|
||||
if (data && !areEqualVersions(currentVersion, data.new_version)) {
|
||||
dispatch(addSuccessToast('updates_checked'));
|
||||
} else {
|
||||
dispatch(addSuccessToast('updates_version_equal'));
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* Checks if versions are equal.
|
||||
* Please note, that this method strips the "v" prefix.
|
||||
*
|
||||
* @param left {string} - left version
|
||||
* @param right {string} - right version
|
||||
* @return {boolean} true if versions are equal
|
||||
*/
|
||||
export const areEqualVersions = (left, right) => {
|
||||
if (!left || !right) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const leftVersion = left.replace(/^v/, '');
|
||||
const rightVersion = right.replace(/^v/, '');
|
||||
return leftVersion === rightVersion;
|
||||
};
|
|
@ -14,6 +14,7 @@ import stats from './stats';
|
|||
import queryLogs from './queryLogs';
|
||||
import dnsConfig from './dnsConfig';
|
||||
import filtering from './filtering';
|
||||
import { areEqualVersions } from '../helpers/version';
|
||||
|
||||
const settings = handleActions(
|
||||
{
|
||||
|
@ -81,7 +82,7 @@ const dashboard = handleActions(
|
|||
[actions.getVersionSuccess]: (state, { payload }) => {
|
||||
const currentVersion = state.dnsVersion === 'undefined' ? 0 : state.dnsVersion;
|
||||
|
||||
if (!payload.disabled && currentVersion !== payload.new_version) {
|
||||
if (!payload.disabled && !areEqualVersions(currentVersion, payload.new_version)) {
|
||||
const {
|
||||
announcement_url: announcementUrl,
|
||||
new_version: newVersion,
|
||||
|
|
Loading…
Reference in New Issue