From cb3fc70491d37f29eb5c4b6413fb992abd6a41cf Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 21 Jan 2025 10:44:06 +0100 Subject: [PATCH] fix(link share): use selected view when opening link share Resolves https://community.vikunja.io/t/selected-view-in-shared-link-not-saved/3250/4 --- .../src/views/sharing/LinkSharingAuth.vue | 52 +++++++++++++------ 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/frontend/src/views/sharing/LinkSharingAuth.vue b/frontend/src/views/sharing/LinkSharingAuth.vue index 8fb1cde98..835ddf43e 100644 --- a/frontend/src/views/sharing/LinkSharingAuth.vue +++ b/frontend/src/views/sharing/LinkSharingAuth.vue @@ -54,6 +54,7 @@ import {LINK_SHARE_HASH_PREFIX} from '@/constants/linkShareHash' import {useBaseStore} from '@/stores/base' import {useAuthStore} from '@/stores/auth' import {useRedirectToLastVisited} from '@/composables/useRedirectToLastVisited' +import type {IProject} from '@/modelTypes/IProject.ts' const {t} = useI18n({useScope: 'global'}) useTitle(t('sharing.authenticating')) @@ -71,6 +72,39 @@ function useAuth() { const password = ref('') const authLinkShare = computed(() => authStore.authLinkShare) + + function redirectToProject(projectId: IProject['id']) { + const hash = LINK_SHARE_HASH_PREFIX + route.params.share + + const viewId = new URLSearchParams(window.location.search).get('view') || null + + const last = getLastVisitedRoute() + if (last) { + return router.push({ + ...last, + hash, + }) + } + + if(viewId) { + return router.push({ + name: 'project.view', + params: { + projectId, + viewId, + }, + hash, + }) + } + + return router.push({ + name: 'project.index', + params: { + projectId, + }, + hash, + }) + } async function authenticate() { authenticateWithPassword.value = false @@ -95,23 +129,7 @@ function useAuth() { : true baseStore.setLogoVisible(logoVisible) - const hash = LINK_SHARE_HASH_PREFIX + route.params.share - - const last = getLastVisitedRoute() - if (last) { - return router.push({ - ...last, - hash, - }) - } - - return router.push({ - name: 'project.index', - params: { - projectId, - }, - hash, - }) + return redirectToProject(projectId) } catch (e) { if (e?.response?.data?.code === 13001) { authenticateWithPassword.value = true