From 2fdda8a22cb46f76c8f92ac2bdcbd9b25acd3e21 Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Thu, 20 Jan 2022 12:23:59 +0300 Subject: [PATCH] Pull request: 4143 sort client ids Merge in DNS/adguard-home from 4143-clients-sort to master Updates #4143. Squashed commit of the following: commit a4b547eb46a54bdfdc7d342fab5f8ecfa54f5d06 Merge: d369c11c d82b2902 Author: Ildar Kamalov Date: Thu Jan 20 11:58:42 2022 +0300 Merge branch 'master' into 4143-clients-sort commit d369c11c69665510043f63e0283e1ca1b2974289 Author: Ildar Kamalov Date: Wed Jan 19 16:53:39 2022 +0300 client: fix sort ip method commit d767a1199c37ad9df7f3bc2d362d840b0226d836 Author: Ildar Kamalov Date: Wed Jan 19 16:23:23 2022 +0300 client: sort client ids --- client/src/components/Settings/Clients/ClientsTable.js | 3 ++- client/src/helpers/helpers.js | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/components/Settings/Clients/ClientsTable.js b/client/src/components/Settings/Clients/ClientsTable.js index ac613164..065157bd 100644 --- a/client/src/components/Settings/Clients/ClientsTable.js +++ b/client/src/components/Settings/Clients/ClientsTable.js @@ -4,7 +4,7 @@ import { Trans, withTranslation } from 'react-i18next'; import ReactTable from 'react-table'; import { MODAL_TYPE } from '../../../helpers/constants'; -import { splitByNewLine, countClientsStatistics } from '../../../helpers/helpers'; +import { splitByNewLine, countClientsStatistics, sortIp } from '../../../helpers/helpers'; import Card from '../../ui/Card'; import Modal from './Modal'; import CellWrap from '../../ui/CellWrap'; @@ -106,6 +106,7 @@ class ClientsTable extends Component { ); }, + sortMethod: sortIp, }, { Header: this.props.t('table_name'), diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js index 6753062a..2546d5b9 100644 --- a/client/src/helpers/helpers.js +++ b/client/src/helpers/helpers.js @@ -754,8 +754,10 @@ const getAddressesComparisonBytes = (item) => { */ export const sortIp = (a, b) => { try { - const comparisonBytesA = getAddressesComparisonBytes(a); - const comparisonBytesB = getAddressesComparisonBytes(b); + const comparisonBytesA = Array.isArray(a) + ? getAddressesComparisonBytes(a[0]) : getAddressesComparisonBytes(a); + const comparisonBytesB = Array.isArray(b) + ? getAddressesComparisonBytes(b[0]) : getAddressesComparisonBytes(b); for (let i = 0; i < comparisonBytesA.length; i += 1) { const byteA = comparisonBytesA[i];