Skip to content

Commit

Permalink
fix: remove useRoute warning
Browse files Browse the repository at this point in the history
  • Loading branch information
preschian committed Dec 15, 2024
1 parent af243fd commit e4ec4b0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
4 changes: 2 additions & 2 deletions components/common/ChainDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class="chain-dropdown-text"
:variant="variant"
:label="
isMobile || !showNetworkLabel
isMobileDevice || !showNetworkLabel
? label || selected?.text
: `Network: ${selected?.text}`
"
Expand All @@ -31,6 +31,7 @@
<script setup lang="ts">
import { NeoButton, NeoDropdown, NeoDropdownItem, type NeoButtonVariant } from '@kodadot1/brick'
import { type Prefix } from '@kodadot1/static'
import { isMobileDevice } from '@/utils/extension'
const props = withDefaults(
defineProps<{
Expand All @@ -57,7 +58,6 @@ const route = useReactiveRoute()
const { setUrlPrefix, urlPrefix } = usePrefix()
const { availableChains: allChains, availableChainsByVm: allChainInVm } = useChain()
const { redirectAfterChainChange } = useChainRedirect()
const { isMobile } = useViewport()
const prefix = computed(() => route.params.prefix || urlPrefix.value)
Expand Down
12 changes: 1 addition & 11 deletions composables/usePrefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,16 @@ import { DEFAULT_PREFIX } from '@kodadot1/static'
import type { Prefix } from '@kodadot1/static'
import { useWalletStore } from '@/stores/wallet'
import { useAssetsStore } from '@/stores/assets'
import { getAvailablePrefix } from '@/utils/chain'

const sharedPrefix = ref<Prefix>()

export default function () {
const route = useRoute()
const storage = useLocalStorage('urlPrefix', { selected: DEFAULT_PREFIX })
const initialPrefixFromPath = getAvailablePrefix(route.path.split('/')[1])
const walletStore = useWalletStore()

const validPrefixFromRoute = computed(() =>
getAvailablePrefix(route.params.prefix),
)

const prefix = computed<Prefix>(
() =>
(sharedPrefix.value
|| validPrefixFromRoute.value
|| storage.value.selected
|| initialPrefixFromPath) as Prefix,
(sharedPrefix.value || storage.value.selected) as Prefix,
)

const handlePrefixChange = (value: Prefix) => {
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/redirect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ test('Redirections', async ({ page }) => {
// Collection
await test.step('Expect collection url to be properly redirected', async () => {
await page.goto('/ahk/explore/gallery')
await expect(page).toHaveURL('/ahk/explore/items')
await expect(page).toHaveURL('/ahk/explore/items?listed=true')
})

// Statemine
await test.step('Expect url with stmn to be properly redirected', async () => {
await page.goto('/stmn/explore/items')
await expect(page).toHaveURL('/ahk/explore/items')
await expect(page).toHaveURL('/ahk/explore/items?listed=true')
})

// Transfer
Expand Down

0 comments on commit e4ec4b0

Please sign in to comment.