From 9e37ed59583fe5e8db91ff576fc9be973223075e Mon Sep 17 00:00:00 2001 From: rui hildt Date: Fri, 2 Feb 2024 23:27:03 +0100 Subject: [PATCH] Fix display of proxy history and improve naming --- src/components/Location.vue | 10 +-- src/components/LocationTabs.vue | 8 +- .../MostUsedLocationButtons.test.ts | 44 ++++++--- src/components/MostUsedLocationButtons.vue | 13 +-- src/components/RecentLocationButtons.vue | 10 +-- .../__snapshots__/Location.test.ts.snap | 89 ++++++++++++++++++- .../HistoricConnections.types.ts | 17 ---- .../useHistoricConnections.ts | 76 ---------------- .../useProxyHistory/HistoryEntries.types.ts | 12 +++ .../useProxyHistory/useProxyHistory.ts | 63 +++++++++++++ src/composables/useStore.ts | 8 +- 11 files changed, 219 insertions(+), 131 deletions(-) delete mode 100644 src/composables/useHistoricConnections/HistoricConnections.types.ts delete mode 100644 src/composables/useHistoricConnections/useHistoricConnections.ts create mode 100644 src/composables/useProxyHistory/HistoryEntries.types.ts create mode 100644 src/composables/useProxyHistory/useProxyHistory.ts diff --git a/src/components/Location.vue b/src/components/Location.vue index acbd90a1..eb9ff3e0 100644 --- a/src/components/Location.vue +++ b/src/components/Location.vue @@ -9,14 +9,14 @@ import useListProxies from '@/composables/useListProxies'; import useSocksProxy from '@/composables/useSocksProxy'; import useLocations from '@/composables/useLocations'; import useActiveTab from '@/composables/useActiveTab'; -import useHistoricConnections from '@/composables/useHistoricConnections/useHistoricConnections'; -import type { HistoricConnection } from '@/composables/useHistoricConnections/HistoricConnections.types'; +import useProxyHistory from '@/composables/useProxyHistory/useProxyHistory'; +import type { HistoryEntry } from '@/composables/useProxyHistory/HistoryEntries.types'; const { activeTabHost } = useActiveTab(); const { hostProxySelect, toggleLocations } = useLocations(); const { proxiesList } = useListProxies(); const { setCurrentHostProxy, setGlobalProxy } = useSocksProxy(); -const { storeSocksProxyUsage } = useHistoricConnections(); +const { storeSocksProxyUsage } = useProxyHistory(); const currentOrAllWebsites = computed(() => hostProxySelect.value ? activeTabHost.value : 'all your browser traffic', @@ -59,10 +59,10 @@ const clickCountryOrCity = (country: string, city?: string) => { setProxy(country, hostname, ipv4_address, city, port); }; -const selectLocation = (connection: HistoricConnection) => { +const selectLocation = (connection: HistoryEntry) => { const { country, city, hostname, ipv4_address } = connection; if (hostname) { - clickSocksProxy(country, city, hostname, ipv4_address); + clickSocksProxy(country, city!, hostname, ipv4_address!); } else { clickCountryOrCity(country, city); } diff --git a/src/components/LocationTabs.vue b/src/components/LocationTabs.vue index 66e2644a..9f26c422 100644 --- a/src/components/LocationTabs.vue +++ b/src/components/LocationTabs.vue @@ -3,8 +3,8 @@ import { NTabPane, NTabs, TabsProps } from 'naive-ui'; import RecentLocationButtons from '@/components/RecentLocationButtons.vue'; import MostUsedLocationButtons from '@/components/MostUsedLocationButtons.vue'; -import useHistoricConnections from '@/composables/useHistoricConnections/useHistoricConnections'; -import type { HistoricConnection } from '@/composables/useHistoricConnections/HistoricConnections.types'; +import useProxyHistory from '@/composables/useProxyHistory/useProxyHistory'; +import type { HistoryEntry } from '@/composables/useProxyHistory/HistoryEntries.types'; type TabsThemeOverrides = NonNullable; const tabsThemeOverrides: TabsThemeOverrides = { @@ -14,9 +14,9 @@ const tabsThemeOverrides: TabsThemeOverrides = { tabTextColorLine: 'var(--light-grey)', }; -defineProps<{ selectLocation: (connection: HistoricConnection) => void }>(); +defineProps<{ selectLocation: (connection: HistoryEntry) => void }>(); -const { mostRecent } = useHistoricConnections(); +const { mostRecent } = useProxyHistory();