fix(submissions): having one scope only make the back return not work

This commit is contained in:
2026-10-15 23:36:06 +02:00
parent 4fd683ff2c
commit b837abdba0
3 changed files with 19 additions and 5 deletions
+5
View File
@@ -528,6 +528,11 @@ onMounted(async () => {
return;
}
scopeName.value = scope.name;
// The picker auto-redirects back here when there's only one scope, so
// going "back" to it would loop - head to the event home instead.
if (scopesResponse.data?.length === 1) {
pageHeaderStore.setBackRoute({ name: "home", params: { eventPath: props.eventPath } });
}
pageHeaderStore.setTitle(t("submissions.pageTitle", { game: gameName.value, scope: scopeName.value }));
// Add paste listener (only processes if hovering upload area)
+2 -2
View File
@@ -12,7 +12,7 @@ const { t } = useI18n();
const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore);
const pageHeaderStore = usePageHeaderStore();
const { title: dynamicTitle } = storeToRefs(pageHeaderStore);
const { title: dynamicTitle, backRoute: dynamicBackRoute } = storeToRefs(pageHeaderStore);
const title = computed(() => {
if (dynamicTitle.value) return dynamicTitle.value;
@@ -21,7 +21,7 @@ const title = computed(() => {
});
const goBack = () => {
const backRoute = route.meta.getBackRoute?.(route);
const backRoute = dynamicBackRoute.value ?? route.meta.getBackRoute?.(route);
if (backRoute) {
router.push(backRoute);
}
+12 -3
View File
@@ -1,5 +1,6 @@
import { defineStore } from "pinia";
import { ref } from "vue";
import type { RouteLocationRaw } from "vue-router";
// Lets a routed page hand AppHeader a title built from data only that page
// has fetched (e.g. "Noita Submissions — Semifinal", assembled from an API
@@ -7,14 +8,22 @@ import { ref } from "vue";
// stale title never lingers while the next page is still loading.
export const usePageHeaderStore = defineStore("pageHeader", () => {
const title = ref("");
// Overrides route.meta.getBackRoute when the right target depends on
// fetched data (e.g. skip the scope picker when it would auto-redirect).
const backRoute = ref<RouteLocationRaw | null>(null);
const setTitle = (value: string) => {
title.value = value;
};
const clear = () => {
title.value = "";
const setBackRoute = (value: RouteLocationRaw) => {
backRoute.value = value;
};
return { title, setTitle, clear };
const clear = () => {
title.value = "";
backRoute.value = null;
};
return { title, backRoute, setTitle, setBackRoute, clear };
});