Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Inject native router only in reactive scopes #1730

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/ui/CollectionCreateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<script setup>
import { XIcon as CrossIcon, CheckIcon, Modal, Button } from 'omorphia'
const router = useRouter()
const router = useNativeRouter()
const name = ref('')
const description = ref('')
Expand Down
4 changes: 2 additions & 2 deletions components/ui/ModerationChecklist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -996,9 +996,9 @@ async function sendMessage(status) {
stopLoading()
}
async function goToNextProject() {
const router = useRouter()
const router = useNativeRouter()
async function goToNextProject() {
const project = props.futureProjects[0]
if (!project) {
Expand Down
2 changes: 1 addition & 1 deletion components/ui/OrganizationCreateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<script setup>
import { XIcon as CrossIcon, CheckIcon, Modal, Button } from 'omorphia'
const router = useRouter()
const router = useNativeRouter()
const name = ref('')
const slug = ref('')
Expand Down
4 changes: 1 addition & 3 deletions components/ui/VersionFilterControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const props = defineProps({
})
const emit = defineEmits(['switch-page'])

const router = useNativeRouter()
const route = useNativeRoute()

const tags = useTags()
Expand Down Expand Up @@ -130,9 +131,6 @@ const selectedLoaders = shallowRef(getArrayOrString(route.query.l) ?? [])
const selectedVersionTypes = shallowRef(getArrayOrString(route.query.c) ?? [])

async function updateQuery() {
const router = useRouter()
const route = useNativeRoute()

await router.replace({
query: {
...route.query,
Expand Down
2 changes: 1 addition & 1 deletion components/ui/charts/ChartDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ import { UiChartsCompactChart as CompactChart, UiChartsChart as Chart } from '#c

import PaletteIcon from '~/assets/icons/palette.svg?component'

const router = useRouter()
const router = useNativeRouter()
const theme = useTheme()

const props = withDefaults(
Expand Down
2 changes: 1 addition & 1 deletion composables/nuxt-bugfest.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { useRoute as useNativeRoute } from 'vue-router'
export { useRoute as useNativeRoute, useRouter as useNativeRouter } from 'vue-router'
5 changes: 2 additions & 3 deletions pages/[type]/[id]/changelog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ useSeoMeta({
ogDescription: description,
})

const router = useNativeRouter()
const route = useNativeRoute()

const currentPage = ref(Number(route.query.p ?? 1))
const filteredVersions = computed(() => {
const selectedGameVersions = getArrayOrString(route.query.g) ?? []
Expand All @@ -126,9 +128,6 @@ const filteredVersions = computed(() => {
function switchPage(page) {
currentPage.value = page

const router = useRouter()
const route = useNativeRoute()

router.replace({
query: {
...route.query,
Expand Down
2 changes: 1 addition & 1 deletion pages/[type]/[id]/settings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ const props = defineProps({
})
const tags = useTags()
const router = useRouter()
const router = useNativeRouter()
const name = ref(props.project.title)
const slug = ref(props.project.slug)
Expand Down
6 changes: 2 additions & 4 deletions pages/[type]/[id]/versions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ useSeoMeta({
ogDescription: description,
})

const router = useNativeRouter()
const route = useNativeRoute()

const currentPage = ref(Number(route.query.p ?? 1))
const filteredVersions = computed(() => {
const selectedGameVersions = getArrayOrString(route.query.g) ?? []
Expand All @@ -174,9 +176,6 @@ const filteredVersions = computed(() => {
function switchPage(page) {
currentPage.value = page

const router = useRouter()
const route = useNativeRoute()

router.replace({
query: {
...route.query,
Expand All @@ -186,7 +185,6 @@ function switchPage(page) {
}

async function handleFiles(files) {
const router = useRouter()
await router.push({
name: 'type-id-version-version',
params: {
Expand Down
2 changes: 1 addition & 1 deletion pages/dashboard/notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ useHead({
const auth = await useAuth()
const route = useNativeRoute()
const router = useRouter()
const router = useNativeRouter()
const history = computed(() => {
return route.name === 'dashboard-notifications-history'
Expand Down
4 changes: 2 additions & 2 deletions pages/moderation/review.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ useHead({

const app = useNuxtApp()

const router = useRouter()

const now = app.$dayjs()
const TIME_24H = 86400000
const TIME_48H = TIME_24H * 2
Expand Down Expand Up @@ -195,8 +197,6 @@ if (projects.value) {
}
}
async function goToProjects() {
const router = useRouter()

const project = projectsFiltered.value[0]
await router.push({
name: 'type-id',
Expand Down
3 changes: 2 additions & 1 deletion pages/search/[searchProjectType].vue
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@ const pageCount = computed(() =>
results.value ? Math.ceil(results.value.total_hits / results.value.limit) : 1
)

const router = useNativeRouter()

function onSearchChange(newPageNumber) {
noLoad.value = true

Expand All @@ -586,7 +588,6 @@ function onSearchChange(newPageNumber) {
refreshSearch()

if (process.client) {
const router = useRouter()
const obj = getSearchUrl((currentPage.value - 1) * maxResults.value, true)
router.replace({ path: route.path, query: obj })
}
Expand Down
Loading