Skip to content

Commit

Permalink
fix: navbar selector
Browse files Browse the repository at this point in the history
  • Loading branch information
preschian committed Apr 12, 2023
1 parent 6ca8208 commit b283f53
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
3 changes: 2 additions & 1 deletion components/navbar/ChainSelectDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import { getChainNameByPrefix } from '@/utils/chain'
const { availableChains } = useChain()
const { $store } = useNuxtApp()
const { urlPrefix } = usePrefix()
const router = useRouter()
const selected = computed({
get: () => $store.getters.getSettings['urlPrefix'],
get: () => urlPrefix.value,
set: (value) => {
$store.dispatch('setUrlPrefix', value)
router.push({ path: `/${value}` })
Expand Down
5 changes: 3 additions & 2 deletions components/navbar/NavbarExploreOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@
</template>

<script lang="ts" setup>
const { $router } = useNuxtApp()
const { $router, $store } = useNuxtApp()
const { urlPrefix } = usePrefix()
const { availableChains } = useChain()
const filteredChains = computed(() => {
return availableChains?.value.filter((chain) => {
return ['ksm', 'bsx', 'rmrk'].includes(chain.value)
return ['ksm', 'bsx', 'rmrk'].includes(chain.value as string)
})
})
const setSelectedChain = (value) => {
$store.dispatch('setUrlPrefix', value)
$router.push({ path: `/${value}/explore` })
}
</script>
3 changes: 1 addition & 2 deletions middleware/prefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export default function ({ store, route }): void {
const { urlPrefix } = usePrefix()

const prefix = urlPrefix.value
const chains = [...chainPrefixes]
const isAnyChainPrefixInPath = chains.includes(prefix)
const isAnyChainPrefixInPath = chainPrefixes.includes(prefix)
const rmrk2ChainPrefixInHostname = rmrk2ChainPrefixesInHostname.find(
(prefix) => location.hostname.startsWith(`${prefix}.`)
)
Expand Down
25 changes: 9 additions & 16 deletions pages/_prefix/explore/index.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
<script lang="ts">
import { Component, Vue } from 'nuxt-property-decorator'
<template>
<!-- empty template, to remove warning "[Vue warn]: Failed to mount component: template or render function not defined." -->
<div></div>
</template>

@Component({
components: {},
})
export default class LandingPage extends Vue {
layout() {
return 'full-width-layout'
}
middleware({ store, redirect }) {
// If the user is not authenticated
const prefix = store.getters.currentUrlPrefix
<script lang="ts" setup>
const router = useRouter()
setTimeout(() => redirect(`/${prefix}/explore/collectibles`))
}
}
onBeforeMount(() => {
router.replace(`${window.location.pathname}/collectibles`)
})
</script>

0 comments on commit b283f53

Please sign in to comment.