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
This commit is contained in:
kolaente 2025-01-21 10:44:06 +01:00
parent b85befb86a
commit cb3fc70491
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
1 changed files with 35 additions and 17 deletions

View File

@ -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