fix(submissions): having one scope only make the back return not work
This commit is contained in:
@@ -528,6 +528,11 @@ onMounted(async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scopeName.value = scope.name;
|
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 }));
|
pageHeaderStore.setTitle(t("submissions.pageTitle", { game: gameName.value, scope: scopeName.value }));
|
||||||
|
|
||||||
// Add paste listener (only processes if hovering upload area)
|
// Add paste listener (only processes if hovering upload area)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const { t } = useI18n();
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const { userInfo } = storeToRefs(userStore);
|
const { userInfo } = storeToRefs(userStore);
|
||||||
const pageHeaderStore = usePageHeaderStore();
|
const pageHeaderStore = usePageHeaderStore();
|
||||||
const { title: dynamicTitle } = storeToRefs(pageHeaderStore);
|
const { title: dynamicTitle, backRoute: dynamicBackRoute } = storeToRefs(pageHeaderStore);
|
||||||
|
|
||||||
const title = computed(() => {
|
const title = computed(() => {
|
||||||
if (dynamicTitle.value) return dynamicTitle.value;
|
if (dynamicTitle.value) return dynamicTitle.value;
|
||||||
@@ -21,7 +21,7 @@ const title = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const goBack = () => {
|
const goBack = () => {
|
||||||
const backRoute = route.meta.getBackRoute?.(route);
|
const backRoute = dynamicBackRoute.value ?? route.meta.getBackRoute?.(route);
|
||||||
if (backRoute) {
|
if (backRoute) {
|
||||||
router.push(backRoute);
|
router.push(backRoute);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
import type { RouteLocationRaw } from "vue-router";
|
||||||
|
|
||||||
// Lets a routed page hand AppHeader a title built from data only that page
|
// 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
|
// 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.
|
// stale title never lingers while the next page is still loading.
|
||||||
export const usePageHeaderStore = defineStore("pageHeader", () => {
|
export const usePageHeaderStore = defineStore("pageHeader", () => {
|
||||||
const title = ref("");
|
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) => {
|
const setTitle = (value: string) => {
|
||||||
title.value = value;
|
title.value = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
const clear = () => {
|
const setBackRoute = (value: RouteLocationRaw) => {
|
||||||
title.value = "";
|
backRoute.value = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
return { title, setTitle, clear };
|
const clear = () => {
|
||||||
|
title.value = "";
|
||||||
|
backRoute.value = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
return { title, backRoute, setTitle, setBackRoute, clear };
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user