Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Names search case insensitive #824

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this logic as there is no way to determine whether the name is in auction or not. It was not even possible before.

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
Loading