From aad86899448e1c612b2adb2dda948a105bf0870f Mon Sep 17 00:00:00 2001 From: janmichek Date: Thu, 30 May 2024 13:24:20 +0200 Subject: [PATCH 1/2] make search case insensitive --- src/components/SearchNamesTable.vue | 2 +- src/stores/search.js | 14 ++++---------- src/utils/adapters.js | 17 ----------------- src/utils/format.js | 10 ---------- 4 files changed, 5 insertions(+), 38 deletions(-) diff --git a/src/components/SearchNamesTable.vue b/src/components/SearchNamesTable.vue index 051b298b2..c1cb7cf15 100644 --- a/src/components/SearchNamesTable.vue +++ b/src/components/SearchNamesTable.vue @@ -25,7 +25,7 @@ {{ name.name }} - {{ name.status }} + {{ name.status ? 'Active' : 'Expired' }} diff --git a/src/stores/search.js b/src/stores/search.js index f5822eab7..ed3a121d5 100644 --- a/src/stores/search.js +++ b/src/stores/search.js @@ -6,21 +6,15 @@ export const useSearchStore = defineStore('search', () => { const { MIDDLEWARE_URL } = useRuntimeConfig().public const axios = useAxios() - const rawNamesResults = ref([]) + const namesResults = ref([]) const tokensResults = ref([]) const nftsResults = ref([]) - const namesResults = computed(() => { - return rawNamesResults.value - ? adaptNamesResults(rawNamesResults.value) - : null - }) - async function fetchNamesResults({ query, limit, queryParameters } = {}) { - rawNamesResults.value = null - const defaultParameters = `/v2/names/search?prefix=${query}&limit=${limit ?? 10}&direction=forward` + namesResults.value = null + const defaultParameters = `/v3/names?prefix=${query}&limit=${limit ?? 10}&by=name` const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`) - rawNamesResults.value = data + namesResults.value = data } async function fetchTokenResults({ query, limit, queryParameters } = {}) { diff --git a/src/utils/adapters.js b/src/utils/adapters.js index 3d0648e8e..de7573551 100644 --- a/src/utils/adapters.js +++ b/src/utils/adapters.js @@ -8,7 +8,6 @@ import { formatDecodeBase64, formatIsAuction, formatNameState, - formatNameStatus, formatTemplateLimit, formatTokenLimit, } from '@/utils/format' @@ -568,22 +567,6 @@ export function adaptStateChannels(stateChannels) { } } -export function adaptNamesResults(names) { - const formattedData = names.data - .map(name => { - return { - name: name.payload.name, - status: formatNameStatus(name), - } - }) - - return { - next: names.next, - data: formattedData, - prev: names.prev, - } -} - export function adaptNftTransfers(transfers) { const formattedData = transfers.data .map(transfer => { diff --git a/src/utils/format.js b/src/utils/format.js index 751500642..156a7f0b4 100644 --- a/src/utils/format.js +++ b/src/utils/format.js @@ -96,16 +96,6 @@ export function formatDecodeByteArray(bytesArray) { return String.fromCharCode(...bytesArray) } -export function formatNameStatus(name) { - if (name.payload.auctionEnd) { - return 'In Auction' - } else if (name.payload.active) { - return 'Active' - } else { - return 'Expired' - } -} - export function formatNameState(name, blockHeight) { const isInAuction = name.status === 'auction' const isActive = name.active From e219317fb1aee82bd24386151ad144b45ac6c726 Mon Sep 17 00:00:00 2001 From: janmichek Date: Mon, 3 Jun 2024 10:37:13 +0200 Subject: [PATCH 2/2] fix displaying status --- src/components/SearchNamesTable.vue | 2 +- src/components/SearchNamesTableCondensed.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/SearchNamesTable.vue b/src/components/SearchNamesTable.vue index c1cb7cf15..6ebbc2f6a 100644 --- a/src/components/SearchNamesTable.vue +++ b/src/components/SearchNamesTable.vue @@ -25,7 +25,7 @@ {{ name.name }} - {{ name.status ? 'Active' : 'Expired' }} + {{ name.active ? 'Active' : 'Expired' }} diff --git a/src/components/SearchNamesTableCondensed.vue b/src/components/SearchNamesTableCondensed.vue index 5f53734f6..6a390778a 100644 --- a/src/components/SearchNamesTableCondensed.vue +++ b/src/components/SearchNamesTableCondensed.vue @@ -30,7 +30,7 @@ - {{ name.status }} + {{ name.active ? 'Active' : 'Expired' }}