Merge pull request #519 from zenodeapp/master

Search bar case sensitivity fix and lowercased chainName
This commit is contained in:
ping 2023-12-05 14:57:37 +08:00 committed by GitHub
commit 489971021e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 11 deletions

View File

@ -32,10 +32,10 @@ function changeEndpoint(item: Endpoint) {
" "
class="capitalize whitespace-nowrap text-base font-semibold text-gray-600 dark:text-gray-200 hidden md:!block" class="capitalize whitespace-nowrap text-base font-semibold text-gray-600 dark:text-gray-200 hidden md:!block"
> >
#{{ {{
baseStore.latest?.block?.header?.height || baseStore.latest?.block?.header?.height
chainStore.chainName || ? `#${baseStore.latest.block.header.height}`
'' : chainStore.chainName || ''
}} <span class="text-error">{{ baseStore.connected ? '' : 'disconnected' }}</span> }} <span class="text-error">{{ baseStore.connected ? '' : 'disconnected' }}</span>
</div> </div>
<div <div

View File

@ -14,8 +14,11 @@ const dashboard = useDashboard();
const keywords = ref(''); const keywords = ref('');
const chains = computed(() => { const chains = computed(() => {
if (keywords.value) { if (keywords.value) {
const lowercaseKeywords = keywords.value.toLowerCase();
return Object.values(dashboard.chains).filter( return Object.values(dashboard.chains).filter(
(x: ChainConfig) => x.chainName.indexOf(keywords.value) > -1 (x: ChainConfig) => x.chainName.toLowerCase().indexOf(lowercaseKeywords) > -1
|| x.prettyName.toLowerCase().indexOf(lowercaseKeywords) > -1
); );
} else { } else {
return Object.values(dashboard.chains); return Object.values(dashboard.chains);

View File

@ -175,9 +175,20 @@ export const useBlockchain = defineStore('blockchain', {
JSON.stringify(endpoint) JSON.stringify(endpoint)
); );
}, },
setCurrent(name: string) { async setCurrent(name: string) {
if (name !== this.chainName) { // Ensure chains are loaded due to asynchronous calls.
this.chainName = name; if(this.dashboard.length === 0) {
await this.dashboard.initial();
}
// Find the case-sensitive name for the chainName, else simply use the parameter-value.
const caseSensitiveName =
Object.keys(this.dashboard.chains).find((x) => x.toLowerCase() === name.toLowerCase())
|| name;
// Update chainName if needed
if (caseSensitiveName !== this.chainName) {
this.chainName = caseSensitiveName;
} }
}, },
supportModule(mod: string) { supportModule(mod: string) {

View File

@ -275,9 +275,9 @@ export const useDashboard = defineStore('dashboard', {
}, },
}, },
actions: { actions: {
initial() { async initial() {
this.loadingFromLocal(); await this.loadingFromLocal();
// this.loadingFromRegistry() // await this.loadingFromRegistry()
}, },
loadingPrices() { loadingPrices() {
const coinIds = [] as string[] const coinIds = [] as string[]