From ab56f6f2815a1aa28e30006f1fd3253a1f4818d4 Mon Sep 17 00:00:00 2001 From: rui hildt Date: Fri, 18 Oct 2024 13:43:21 +0200 Subject: [PATCH] Implement search based on @hankolsen previous PR --- src/components/Location.test.ts | 2 +- src/components/Location.vue | 19 ++++-- src/components/LocationTabs.vue | 2 +- src/components/Proxy/HomeProxyStatus.vue | 4 +- src/components/SearchLocation.vue | 10 +++ .../__snapshots__/Location.test.ts.snap | 64 ++++++++++++++++++- .../useSocksProxies/useSocksProxies.ts | 34 ++++++++-- src/composables/useStore.ts | 8 +-- 8 files changed, 122 insertions(+), 21 deletions(-) create mode 100644 src/components/SearchLocation.vue diff --git a/src/components/Location.test.ts b/src/components/Location.test.ts index e93b9078..9fb2db0a 100644 --- a/src/components/Location.test.ts +++ b/src/components/Location.test.ts @@ -13,7 +13,7 @@ jest.mock('@/composables/useActiveTab', () => ({ jest.mock('@/composables/useSocksProxies/useSocksProxies', () => ({ __esModule: true, default: jest.fn(() => ({ - proxiesList: [ + filteredProxies: [ { country: 'Albania', }, diff --git a/src/components/Location.vue b/src/components/Location.vue index 21745393..5ef2ac12 100644 --- a/src/components/Location.vue +++ b/src/components/Location.vue @@ -3,18 +3,20 @@ import { computed } from 'vue'; import { NButton, NCollapse, NCollapseItem, NSpace } from 'naive-ui'; import LocationTabs from '@/components/LocationTabs.vue'; +import SearchLocation from '@/components/SearchLocation.vue'; import getRandomSocksProxy from '@/helpers/getRandomSocksProxy'; import { updateCurrentTabProxyBadge } from '@/helpers/proxyBadge'; -import useListProxies from '@/composables/useSocksProxies/useSocksProxies'; +import useSocksProxies from '@/composables/useSocksProxies/useSocksProxies'; import useSocksProxy from '@/composables/useSocksProxy'; import useLocations from '@/composables/useLocations'; import useProxyHistory from '@/composables/useProxyHistory/useProxyHistory'; import type { HistoryEntry } from '@/composables/useProxyHistory/HistoryEntries.types'; const { customProxyHost, customProxySelect, toggleLocations } = useLocations(); -const { proxiesList } = useListProxies(); +const { clearFilter, filteredProxies } = useSocksProxies(); + const { setCurrentHostProxy, setGlobalProxy } = useSocksProxy(); const { storeSocksProxyUsage } = useProxyHistory(); @@ -54,16 +56,18 @@ const clickServer = ( port?: number, ) => { setProxy(country, countryCode, city, hostname, ipv4_address, port); + clearFilter(); }; const clickCountryOrCity = (selectedCountry: string, selectedCity?: string) => { const { country, countryCode, city, hostname, ipv4_address, port } = getRandomSocksProxy({ - socksProxies: proxiesList.value, + socksProxies: filteredProxies.value, country: selectedCountry, city: selectedCity, }); setProxy(country, countryCode, city, hostname, ipv4_address, port); + clearFilter(); }; const selectLocation = (connection: HistoryEntry) => { @@ -77,13 +81,18 @@ const selectLocation = (connection: HistoryEntry) => {