Skip to content

Commit 6583f84

Browse files
committed
Bookmarks search
1 parent d1f38dc commit 6583f84

File tree

5 files changed

+68
-17
lines changed

5 files changed

+68
-17
lines changed

assets/icons.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"unselect": "M13 2C13 1.44772 12.5523 1 12 1C11.4477 1 11 1.44772 11 2V3.05493C6.82838 3.51608 3.51608 6.82838 3.05493 11H2C1.44772 11 1 11.4477 1 12C1 12.5523 1.44772 13 2 13H3.05493C3.51608 17.1716 6.82838 20.4839 11 20.9451V22C11 22.5523 11.4477 23 12 23C12.5523 23 13 22.5523 13 22V20.9451C17.1716 20.4839 20.4839 17.1716 20.9451 13H22C22.5523 13 23 12.5523 23 12C23 11.4477 22.5523 11 22 11H20.9451C20.4839 6.82838 17.1716 3.51608 13 3.05493V2ZM7 12C7 9.23858 9.23858 7 12 7C14.7614 7 17 9.23858 17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12Z",
2323
"download": "M12 2C12.5523 2 13 2.44772 13 3V12.5858L16.2929 9.29289C16.6834 8.90237 17.3166 8.90237 17.7071 9.29289C18.0976 9.68342 18.0976 10.3166 17.7071 10.7071L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L6.29289 10.7071C5.90237 10.3166 5.90237 9.68342 6.29289 9.29289C6.68342 8.90237 7.31658 8.90237 7.70711 9.29289L11 12.5858V3C11 2.44772 11.4477 2 12 2ZM4 15C4 14.4477 3.55229 14 3 14C2.44772 14 2 14.4477 2 15V16.2413V16.2414C1.99999 17.0464 1.99998 17.7106 2.04419 18.2518C2.09012 18.8139 2.18868 19.3306 2.43598 19.816C2.81947 20.5686 3.43139 21.1805 4.18404 21.564C4.66937 21.8113 5.18608 21.9099 5.74818 21.9558C6.28937 22 6.95373 22 7.7587 22H16.2413C17.0463 22 17.7106 22 18.2518 21.9558C18.8139 21.9099 19.3306 21.8113 19.816 21.564C20.5686 21.1805 21.1805 20.5686 21.564 19.816C21.8113 19.3306 21.9099 18.8139 21.9558 18.2518C22 17.7106 22 17.0463 22 16.2413V15C22 14.4477 21.5523 14 21 14C20.4477 14 20 14.4477 20 15V16.2C20 17.0566 19.9992 17.6389 19.9624 18.089C19.9266 18.5274 19.8617 18.7516 19.782 18.908C19.5903 19.2843 19.2843 19.5903 18.908 19.782C18.7516 19.8617 18.5274 19.9266 18.089 19.9624C17.6389 19.9992 17.0566 20 16.2 20H7.8C6.94342 20 6.36113 19.9992 5.91104 19.9624C5.47262 19.9266 5.24842 19.8617 5.09202 19.782C4.7157 19.5903 4.40973 19.2843 4.21799 18.908C4.1383 18.7516 4.07337 18.5274 4.03755 18.089C4.00078 17.6389 4 17.0566 4 16.2V15Z",
2424
"upload": "M12.7071 2.29289C12.3166 1.90237 11.6834 1.90237 11.2929 2.29289L6.29289 7.29289C5.90237 7.68342 5.90237 8.31658 6.29289 8.70711C6.68342 9.09763 7.31658 9.09763 7.70711 8.70711L11 5.41421V15C11 15.5523 11.4477 16 12 16C12.5523 16 13 15.5523 13 15V5.41421L16.2929 8.70711C16.6834 9.09763 17.3166 9.09763 17.7071 8.70711C18.0976 8.31658 18.0976 7.68342 17.7071 7.29289L12.7071 2.29289ZM4 15C4 14.4477 3.55229 14 3 14C2.44772 14 2 14.4477 2 15V16.2413V16.2414C1.99999 17.0464 1.99998 17.7106 2.04419 18.2518C2.09012 18.8139 2.18868 19.3306 2.43598 19.816C2.81947 20.5686 3.43139 21.1805 4.18404 21.564C4.66937 21.8113 5.18608 21.9099 5.74818 21.9558C6.28937 22 6.95373 22 7.7587 22H16.2413C17.0463 22 17.7106 22 18.2518 21.9558C18.8139 21.9099 19.3306 21.8113 19.816 21.564C20.5686 21.1805 21.1805 20.5686 21.564 19.816C21.8113 19.3306 21.9099 18.8139 21.9558 18.2518C22 17.7106 22 17.0463 22 16.2413V15C22 14.4477 21.5523 14 21 14C20.4477 14 20 14.4477 20 15V16.2C20 17.0566 19.9992 17.6389 19.9624 18.089C19.9266 18.5274 19.8617 18.7516 19.782 18.908C19.5903 19.2843 19.2843 19.5903 18.908 19.782C18.7516 19.8617 18.5274 19.9266 18.089 19.9624C17.6389 19.9992 17.0566 20 16.2 20H7.8C6.94342 20 6.36113 19.9992 5.91104 19.9624C5.47262 19.9266 5.24842 19.8617 5.09202 19.782C4.7157 19.5903 4.40973 19.2843 4.21799 18.908C4.1383 18.7516 4.07337 18.5274 4.03755 18.089C4.00078 17.6389 4 17.0566 4 16.2V15Z",
25+
"bookmark": "M9.7587 2H14.2413C15.0463 1.99999 15.7106 1.99998 16.2518 2.04419C16.8139 2.09012 17.3306 2.18868 17.816 2.43597C18.5686 2.81947 19.1805 3.43139 19.564 4.18404C19.8113 4.66937 19.9099 5.18608 19.9558 5.74817C20 6.28938 20 6.95374 20 7.75873V21C20 21.3565 19.8102 21.686 19.5019 21.8649C19.1936 22.0438 18.8134 22.0451 18.5039 21.8682L12 18.1518L5.49614 21.8682C5.18664 22.0451 4.80639 22.0438 4.49807 21.8649C4.18976 21.686 4 21.3565 4 21V7.7587C3.99999 6.95373 3.99998 6.28937 4.04419 5.74817C4.09012 5.18608 4.18868 4.66937 4.43597 4.18404C4.81947 3.43139 5.43139 2.81947 6.18404 2.43597C6.66937 2.18868 7.18608 2.09012 7.74817 2.04419C8.28937 1.99998 8.95373 1.99999 9.7587 2Z",
2526
"bookmark-plus": "M14.2413 2H9.7587C8.95374 1.99999 8.28937 1.99998 7.74818 2.04419C7.18608 2.09012 6.66937 2.18868 6.18404 2.43598C5.43139 2.81947 4.81947 3.43139 4.43598 4.18404C4.18868 4.66937 4.09012 5.18608 4.04419 5.74818C3.99998 6.28937 3.99999 6.95372 4 7.75869V21C4 21.3565 4.18976 21.686 4.49807 21.8649C4.80639 22.0438 5.18664 22.0451 5.49614 21.8682L12 18.1518L18.5039 21.8682C18.8134 22.0451 19.1936 22.0438 19.5019 21.8649C19.8102 21.686 20 21.3565 20 21V7.75873C20 6.95376 20 6.28937 19.9558 5.74818C19.9099 5.18608 19.8113 4.66937 19.564 4.18404C19.1805 3.43139 18.5686 2.81947 17.816 2.43598C17.3306 2.18868 16.8139 2.09012 16.2518 2.04419C15.7106 1.99998 15.0463 1.99999 14.2413 2ZM12 6C12.5523 6 13 6.44772 13 7V9H15C15.5523 9 16 9.44772 16 10C16 10.5523 15.5523 11 15 11H13V13C13 13.5523 12.5523 14 12 14C11.4477 14 11 13.5523 11 13V11H9C8.44772 11 8 10.5523 8 10C8 9.44772 8.44772 9 9 9H11V7C11 6.44772 11.4477 6 12 6Z",
2627
"bookmark-check": "M 14.242 2 C 15.046 2 15.71 2 16.252 2.044 C 16.814 2.09 17.331 2.189 17.816 2.436 C 18.569 2.819 19.181 3.431 19.564 4.184 C 19.811 4.669 19.91 5.186 19.956 5.749 C 20 6.289 20 6.954 20 7.759 L 20 21 C 20 21.356 19.81 21.686 19.502 21.865 C 19.194 22.043 18.813 22.045 18.504 21.868 L 12 18.152 L 5.496 21.868 C 5.187 22.045 4.806 22.043 4.498 21.865 C 4.19 21.686 4 21.356 4 21 L 4 7.758 C 4 6.954 4 6.29 4.045 5.748 C 4.091 5.186 4.19 4.669 4.437 4.184 C 4.82 3.431 5.432 2.819 6.185 2.436 C 6.67 2.189 7.187 2.09 7.75 2.044 C 8.29 2 8.955 2 9.76 2 Z M 16.207 8.707 C 16.586 8.315 16.581 7.691 16.195 7.305 C 15.809 6.919 15.185 6.914 14.793 7.293 L 11 11.086 L 9.707 9.793 C 9.315 9.414 8.691 9.419 8.305 9.805 C 7.919 10.191 7.914 10.815 8.293 11.207 L 10.293 13.207 C 10.683 13.597 11.317 13.597 11.707 13.207 Z",
2728
"bookmark-x": "M14.2413 2H9.7587C8.95374 1.99999 8.28937 1.99998 7.74818 2.04419C7.18608 2.09012 6.66937 2.18868 6.18404 2.43598C5.43139 2.81947 4.81947 3.43139 4.43598 4.18404C4.18868 4.66937 4.09012 5.18608 4.04419 5.74818C3.99998 6.28937 3.99999 6.95372 4 7.75869V21C4 21.3565 4.18976 21.686 4.49807 21.8649C4.80639 22.0438 5.18664 22.0451 5.49614 21.8682L12 18.1518L18.5039 21.8682C18.8134 22.0451 19.1936 22.0438 19.5019 21.8649C19.8102 21.686 20 21.3565 20 21V7.75873C20 6.95376 20 6.28937 19.9558 5.74818C19.9099 5.18608 19.8113 4.66937 19.564 4.18404C19.1805 3.43139 18.5686 2.81947 17.816 2.43598C17.3306 2.18868 16.8139 2.09012 16.2518 2.04419C15.7106 1.99998 15.0463 1.99999 14.2413 2ZM8.79289 6.79289C9.18342 6.40237 9.81658 6.40237 10.2071 6.79289L12 8.58579L13.7929 6.79289C14.1834 6.40237 14.8166 6.40237 15.2071 6.79289C15.5976 7.18342 15.5976 7.81658 15.2071 8.20711L13.4142 10L15.2071 11.7929C15.5976 12.1834 15.5976 12.8166 15.2071 13.2071C14.8166 13.5976 14.1834 13.5976 13.7929 13.2071L12 11.4142L10.2071 13.2071C9.81658 13.5976 9.18342 13.5976 8.79289 13.2071C8.40237 12.8166 8.40237 12.1834 8.79289 11.7929L10.5858 10L8.79289 8.20711C8.40237 7.81658 8.40237 7.18342 8.79289 6.79289Z",

components/Connection.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,16 @@ const handleDisconnect = () => {
149149
</Tooltip>
150150
151151
<Tooltip v-else-if="!isWalletAvailable" position="end">
152-
<Button type="white" size="small" disabled> Connect </Button>
152+
<Button type="white" size="mini" disabled> Connect </Button>
153153
154154
<template #content> Insall Keplr Wallet before connection </template>
155155
</Tooltip>
156156
157-
<Button v-else-if="!appStore.address" @click="handleConnect" type="white" size="small"> Connect </Button>
157+
<Button v-else-if="!appStore.address" @click="handleConnect" type="white" size="mini"> Connect </Button>
158158
159159
<Dropdown v-else>
160-
<Button type="secondary" size="small">
161-
<Icon name="address" size="14" color="primary" />
160+
<Button type="secondary" size="mini">
161+
<Icon name="address" size="13" color="primary" />
162162
{{ appStore.balance }} TIA
163163
</Button>
164164

components/TheHeader.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ const handleNavigate = (url) => {
156156
</template>
157157
</Tooltip>
158158

159+
<Tooltip position="end" delay="250">
160+
<NuxtLink to="/bookmarks">
161+
<Button type="secondary" size="mini">
162+
<Icon name="bookmark" size="16" color="secondary" />
163+
</Button>
164+
</NuxtLink>
165+
166+
<template #content>
167+
<Flex align="center" gap="8">
168+
Open My Bookmarks
169+
</Flex>
170+
</template>
171+
</Tooltip>
172+
159173
<Connection :class="$style.connection_btn" />
160174
</Flex>
161175
</Flex>

components/cmd/CommandMenu.vue

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,7 @@ const searchAction = {
862862
if (!searchTerm.value.length) return
863863
864864
const { data } = await search(searchTerm.value.trim())
865+
console.log('Manual search data', data);
865866
if (!data.value.length) {
866867
notificationsStore.create({
867868
notification: {
@@ -922,7 +923,14 @@ const autocompleteGroup = computed(() => {
922923
})
923924
924925
const debouncedSearch = useDebounceFn(async (e) => {
926+
const bookmarks = bookmarksStore.searchBookmark(searchTerm.value)
925927
const { data } = await search(searchTerm.value.trim())
928+
929+
data.value = [...bookmarks, ...data.value]
930+
931+
console.log('debouncedSearch data', data);
932+
console.log('debouncedSearch bookmarks', bookmarks);
933+
926934
if (!data.value?.length) return
927935
928936
amp.log("showAutocomplete", { count: data.value.length, firstType: data.value[0].type })
@@ -934,23 +942,23 @@ const debouncedSearch = useDebounceFn(async (e) => {
934942
let routerLink
935943
switch (data.value[i].type) {
936944
case "tx":
937-
title = data.value[i].result.hash
938-
routerLink = `/tx/${data.value[i].result.hash}`
945+
title = data.value[i].result.alias || data.value[i].result.hash
946+
routerLink = `/tx/${data.value[i].result.id || data.value[i].result.hash}`
939947
break
940948
941949
case "block":
942-
title = data.value[i].result.hash
943-
routerLink = `/block/${data.value[i].result.height}`
950+
title = data.value[i].result.alias || data.value[i].result.hash
951+
routerLink = `/block/${data.value[i].result.id || data.value[i].result.height}`
944952
break
945953
946954
case "namespace":
947-
title = data.value[i].result.hash
948-
routerLink = `/namespace/${data.value[i].result.namespace_id}`
955+
title = data.value[i].result.alias || data.value[i].result.hash
956+
routerLink = `/namespace/${data.value[i].result.id || data.value[i].result.namespace_id}`
949957
break
950958
951959
case "address":
952-
title = data.value[i].result.hash
953-
routerLink = `/address/${data.value[i].result.hash}`
960+
title = data.value[i].result.alias || data.value[i].result.hash
961+
routerLink = `/address/${data.value[i].result.id || data.value[i].result.hash}`
954962
break
955963
956964
case "rollup":
@@ -959,7 +967,7 @@ const debouncedSearch = useDebounceFn(async (e) => {
959967
break
960968
961969
case "validator":
962-
title = data.value[i].result.moniker ? data.value[i].result.moniker : data.value[i].result.address
970+
title = data.value[i].result.alias || data.value[i].result.moniker ? data.value[i].result.moniker : data.value[i].result.address
963971
routerLink = `/validator/${data.value[i].result.id}`
964972
break
965973

store/bookmarks.js

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ export const useBookmarksStore = defineStore("bookmarks", () => {
1818
const hasBookmarks = computed(() => {
1919
let has = false
2020

21-
Object.keys(bookmarks.value).forEach((b) => {
22-
if (bookmarks.value[b].length) has = true
23-
})
21+
let keys = Object.keys(bookmarks.value)
22+
for (let i = 0; i < keys.length; i++) {
23+
if (bookmarks.value[keys[i]].length) {
24+
has = true
25+
break
26+
}
27+
}
2428

2529
return has
2630
})
2731

2832
const getBookmarkAlias = (type, id) => {
33+
if (!hasBookmarks) return id
34+
2935
let store = getStoreByType(type)
3036

3137
if (!store) return id
@@ -41,6 +47,8 @@ export const useBookmarksStore = defineStore("bookmarks", () => {
4147
}
4248

4349
const getBookmark = (type, id) => {
50+
if (!hasBookmarks) return null
51+
4452
let store = getStoreByType(type)
4553

4654
if (!store) return null
@@ -97,13 +105,33 @@ export const useBookmarksStore = defineStore("bookmarks", () => {
97105
}
98106
}
99107

108+
const searchBookmark = (searchString) => {
109+
if (!hasBookmarks) return []
110+
111+
let res = []
112+
113+
Object.keys(bookmarks.value).forEach((b) => {
114+
115+
bookmarks.value[b].forEach((el) => {
116+
if (el.alias?.toUpperCase().includes(searchString.toUpperCase())) {
117+
res.push({
118+
result: el,
119+
type: el.type.toLowerCase(),
120+
})
121+
}
122+
})
123+
})
124+
125+
return res
126+
}
127+
100128
const clearBookmarks = () => {
101129
Object.keys(bookmarks.value).forEach((b) => {
102130
bookmarks.value[b] = []
103131
})
104132
}
105133

106-
return { bookmarks, hasBookmarks, recentBookmarks, addBookmark, clearBookmarks, getBookmark, getBookmarkAlias, removeBookmark }
134+
return { bookmarks, hasBookmarks, recentBookmarks, addBookmark, clearBookmarks, getBookmark, getBookmarkAlias, removeBookmark, searchBookmark }
107135
})
108136

109137
if (import.meta.hot) {

0 commit comments

Comments
 (0)