Skip to content

Commit

Permalink
feat: Names search case insensitive (#824)
Browse files Browse the repository at this point in the history
  • Loading branch information
janmichek authored Jun 3, 2024
1 parent 44ee1fc commit a1e187b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/components/SearchNamesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{ name.name }}
</app-link>
</td>
<td>{{ name.status }}</td>
<td>{{ name.active ? 'Active' : 'Expired' }}</td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchNamesTableCondensed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</app-tooltip>
</th>
<td class="search-names-table-condensed__data">
{{ name.status }}
{{ name.active ? 'Active' : 'Expired' }}
</td>
</tr>
</tbody>
Expand Down
14 changes: 4 additions & 10 deletions src/stores/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } = {}) {
Expand Down
17 changes: 0 additions & 17 deletions src/utils/adapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
formatDecodeBase64,
formatIsAuction,
formatNameState,
formatNameStatus,
formatTemplateLimit,
formatTokenLimit,
} from '@/utils/format'
Expand Down Expand Up @@ -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 => {
Expand Down
10 changes: 0 additions & 10 deletions src/utils/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a1e187b

Please sign in to comment.