Skip to content

Commit

Permalink
fix: enable nav commands only once
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Dec 29, 2022
1 parent 524f700 commit 1054e55
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
21 changes: 12 additions & 9 deletions components/nav/NavSide.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<script setup lang="ts">
const { command } = defineProps<{
command?: boolean
}>()
const { notifications } = useNotifications()
</script>

<template>
<nav sm:px3 sm:py4 flex="~ col gap2" text-size-base leading-normal md:text-lg>
<NavSideItem :text="$t('nav.home')" to="/home" icon="i-ri:home-5-line" user-only />
<NavSideItem :text="$t('nav.notifications')" to="/notifications" icon="i-ri:notification-4-line" user-only>
<NavSideItem :text="$t('nav.home')" to="/home" icon="i-ri:home-5-line" user-only :command="command" />
<NavSideItem :text="$t('nav.notifications')" to="/notifications" icon="i-ri:notification-4-line" user-only :command="command">
<template #icon>
<div flex relative>
<div class="i-ri:notification-4-line" md:text-size-inherit text-xl />
Expand All @@ -17,13 +20,13 @@ const { notifications } = useNotifications()
</NavSideItem>

<!-- Use Search for small screens once the right sidebar is collapsed -->
<NavSideItem :text="$t('nav.search')" to="/search" icon="i-ri:search-line" lg:hidden />
<NavSideItem :text="$t('nav.explore')" :to="`/${currentServer}/explore`" icon="i-ri:hashtag" />
<NavSideItem :text="$t('nav.search')" to="/search" icon="i-ri:search-line" lg:hidden :command="command" />
<NavSideItem :text="$t('nav.explore')" :to="`/${currentServer}/explore`" icon="i-ri:hashtag" :command="command" />

<NavSideItem :text="$t('nav.local')" :to="`/${currentServer}/public/local`" icon="i-ri:group-2-line " />
<NavSideItem :text="$t('nav.federated')" :to="`/${currentServer}/public`" icon="i-ri:earth-line" />
<NavSideItem :text="$t('nav.conversations')" to="/conversations" icon="i-ri:at-line" user-only />
<NavSideItem :text="$t('nav.favourites')" to="/favourites" icon="i-ri:heart-3-line" user-only />
<NavSideItem :text="$t('nav.bookmarks')" to="/bookmarks" icon="i-ri:bookmark-line " user-only />
<NavSideItem :text="$t('nav.local')" :to="`/${currentServer}/public/local`" icon="i-ri:group-2-line " :command="command" />
<NavSideItem :text="$t('nav.federated')" :to="`/${currentServer}/public`" icon="i-ri:earth-line" :command="command" />
<NavSideItem :text="$t('nav.conversations')" to="/conversations" icon="i-ri:at-line" user-only :command="command" />
<NavSideItem :text="$t('nav.favourites')" to="/favourites" icon="i-ri:heart-3-line" user-only :command="command" />
<NavSideItem :text="$t('nav.bookmarks')" to="/bookmarks" icon="i-ri:bookmark-line " user-only :command="command" />
</nav>
</template>
4 changes: 4 additions & 0 deletions components/nav/NavSideItem.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<script setup lang="ts">
import { warn } from 'vue'
const props = withDefaults(defineProps<{
text?: string
icon: string
to: string | Record<string, string>
userOnly?: boolean
command?: boolean
}>(), {
userOnly: false,
})
Expand All @@ -20,6 +23,7 @@ useCommand({
name: () => props.text ?? (typeof props.to === 'string' ? props.to as string : props.to.name),
icon: () => props.icon,
visible: () => props.command,
onActivate() {
router.push(props.to)
Expand Down
19 changes: 9 additions & 10 deletions components/settings/SettingsNavItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ const props = defineProps<{
const router = useRouter()
if (props.command) {
useCommand({
scope: 'Settings',
useCommand({
scope: 'Settings',
name: () => props.text ?? (typeof props.to === 'string' ? props.to as string : props.to.name),
icon: () => props.icon || '',
name: () => props.text ?? (typeof props.to === 'string' ? props.to as string : props.to.name),
icon: () => props.icon || '',
visible: () => props.command,
onActivate() {
router.push(props.to)
},
})
}
onActivate() {
router.push(props.to)
},
})
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const wideLayout = computed(() => route.meta.wideLayout ?? false)
<NavTitle mt4 mb2 lg:mx-3 />
<div flex="~ col" overflow-y-auto justify-between h-full max-w-full>
<div flex flex-col>
<NavSide />
<NavSide command />
<PublishButton m="y5 xa" lg:m="r5 l3" lg:rtl-m="l5 r3" />
</div>
<div v-if="isMastoInitialised" flex flex-col>
Expand Down

0 comments on commit 1054e55

Please sign in to comment.