- client: 2300 Fix block client bug when clients values are empty in config

Close #2300

Squashed commit of the following:

commit 7222a03ebf3bf8aa93fbd819227e1d5caacce92b
Merge: 91b06b10e 09196118e
Author: Artem Baskal <a.baskal@adguard.com>
Date:   Mon Nov 16 12:46:26 2020 +0300

    Merge branch 'master' into fix/2300

commit 91b06b10e5d46472c9474032d0ae11dc8d0e4609
Author: Artem Baskal <a.baskal@adguard.com>
Date:   Fri Nov 13 15:12:31 2020 +0300

    - client: 2300 Fix block client bug when clients values are empty in config
This commit is contained in:
Artem Baskal 2020-11-16 12:56:55 +03:00
parent 09196118e9
commit 394fc5a9d8

View File

@ -51,9 +51,10 @@ export const toggleClientBlockSuccess = createAction('TOGGLE_CLIENT_BLOCK_SUCCES
export const toggleClientBlock = (ip, disallowed, disallowed_rule) => async (dispatch) => {
dispatch(toggleClientBlockRequest());
try {
const {
allowed_clients, blocked_hosts, disallowed_clients = [],
} = await apiClient.getAccessList();
const accessList = await apiClient.getAccessList();
const allowed_clients = accessList.allowed_clients ?? [];
const blocked_hosts = accessList.blocked_hosts ?? [];
const disallowed_clients = accessList.disallowed_clients ?? [];
const updatedDisallowedClients = disallowed
? disallowed_clients.filter((client) => client !== disallowed_rule)