- client: fix update now button and notification

This commit is contained in:
Ildar Kamalov 2019-07-05 18:21:46 +03:00
parent e03efbcdd1
commit 2fe9819150
3 changed files with 20 additions and 7 deletions

View File

@ -1,4 +1,5 @@
{ {
"client_settings": "Client settings",
"example_upstream_reserved": "you can specify DNS upstream <0>for a specific domain(s)<\/0>", "example_upstream_reserved": "you can specify DNS upstream <0>for a specific domain(s)<\/0>",
"upstream_parallel": "Use parallel queries to speed up resolving by simultaneously querying all upstream servers", "upstream_parallel": "Use parallel queries to speed up resolving by simultaneously querying all upstream servers",
"bootstrap_dns": "Bootstrap DNS servers", "bootstrap_dns": "Bootstrap DNS servers",
@ -52,7 +53,7 @@
"filters": "Filters", "filters": "Filters",
"query_log": "Query Log", "query_log": "Query Log",
"faq": "FAQ", "faq": "FAQ",
"version": "version", "version": "Version",
"address": "address", "address": "address",
"on": "ON", "on": "ON",
"off": "OFF", "off": "OFF",
@ -99,7 +100,6 @@
"dns_settings": "DNS settings", "dns_settings": "DNS settings",
"encryption_settings": "Encryption settings", "encryption_settings": "Encryption settings",
"dhcp_settings": "DHCP settings", "dhcp_settings": "DHCP settings",
"client_settings": "Client settings",
"upstream_dns": "Upstream DNS servers", "upstream_dns": "Upstream DNS servers",
"upstream_dns_hint": "If you keep this field empty, AdGuard Home will use <a href='https:\/\/1.1.1.1\/' target='_blank'>Cloudflare DNS<\/a> as an upstream.", "upstream_dns_hint": "If you keep this field empty, AdGuard Home will use <a href='https:\/\/1.1.1.1\/' target='_blank'>Cloudflare DNS<\/a> as an upstream.",
"test_upstream_btn": "Test upstreams", "test_upstream_btn": "Test upstreams",
@ -314,6 +314,7 @@
"access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in query's question.", "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in query's question.",
"access_settings_saved": "Access settings successfully saved", "access_settings_saved": "Access settings successfully saved",
"updates_checked": "Updates successfully checked", "updates_checked": "Updates successfully checked",
"updates_version_equal": "AdGuard Home is up-to-date",
"check_updates_now": "Check for updates now", "check_updates_now": "Check for updates now",
"dns_privacy": "DNS Privacy", "dns_privacy": "DNS Privacy",
"setup_dns_privacy_1": "<0>DNS-over-TLS:</0> Use <1>{{address}}</1> string.", "setup_dns_privacy_1": "<0>DNS-over-TLS:</0> Use <1>{{address}}</1> string.",

View File

@ -4,6 +4,7 @@ import { t } from 'i18next';
import { showLoading, hideLoading } from 'react-redux-loading-bar'; import { showLoading, hideLoading } from 'react-redux-loading-bar';
import axios from 'axios'; import axios from 'axios';
import versionCompare from '../helpers/versionCompare';
import { normalizeHistory, normalizeFilteringStatus, normalizeLogs, normalizeTextarea, sortClients } from '../helpers/helpers'; import { normalizeHistory, normalizeFilteringStatus, normalizeLogs, 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';
@ -146,13 +147,21 @@ export const getVersionRequest = createAction('GET_VERSION_REQUEST');
export const getVersionFailure = createAction('GET_VERSION_FAILURE'); export const getVersionFailure = createAction('GET_VERSION_FAILURE');
export const getVersionSuccess = createAction('GET_VERSION_SUCCESS'); export const getVersionSuccess = createAction('GET_VERSION_SUCCESS');
export const getVersion = (recheck = false) => async (dispatch) => { export const getVersion = (recheck = false) => async (dispatch, getState) => {
dispatch(getVersionRequest()); dispatch(getVersionRequest());
try { try {
const newVersion = await apiClient.getGlobalVersion({ recheck_now: recheck }); const data = await apiClient.getGlobalVersion({ recheck_now: recheck });
dispatch(getVersionSuccess(newVersion)); dispatch(getVersionSuccess(data));
if (recheck) { if (recheck) {
dispatch(addSuccessToast('updates_checked')); const { dnsVersion } = getState().dashboard;
const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion;
if (data && versionCompare(currentVersion, data.new_version) === -1) {
dispatch(addSuccessToast('updates_checked'));
} else {
dispatch(addSuccessToast('updates_version_equal'));
}
} }
} catch (error) { } catch (error) {
dispatch(addErrorToast({ error })); dispatch(addErrorToast({ error }));

View File

@ -142,7 +142,10 @@ const dashboard = handleActions({
return newState; return newState;
} }
return state; return {
...state,
processingVersion: false,
};
}, },
[actions.getUpdateRequest]: state => ({ ...state, processingUpdate: true }), [actions.getUpdateRequest]: state => ({ ...state, processingUpdate: true }),