Skip to content
Open
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
22 changes: 20 additions & 2 deletions src/Forms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ import { loadState } from '@nextcloud/initial-state'
import moment from '@nextcloud/moment'
import { generateOcsUrl } from '@nextcloud/router'
import { useIsMobile } from '@nextcloud/vue'
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import NcAppContent from '@nextcloud/vue/components/NcAppContent'
import NcAppNavigation from '@nextcloud/vue/components/NcAppNavigation'
Expand Down Expand Up @@ -205,6 +205,7 @@ export default {
const allSharedForms = ref([])
const showArchivedForms = ref(false)
const canCreateForms = ref(loadState(appName, 'appConfig').canCreateForms)
const deletedFormHash = ref(null)

const PERMISSION_TYPES = PermissionTypes.data().PERMISSION_TYPES

Expand All @@ -219,6 +220,11 @@ export default {
return false
}

// Don't try to fetch if this form was just deleted
if (deletedFormHash.value === routeHash.value) {
return false
}

const form = [...forms.value, ...allSharedForms.value].find(
(form) => form.hash === routeHash.value,
)
Expand Down Expand Up @@ -435,12 +441,24 @@ export default {
const deletedHash = forms.value[formIndex].hash

forms.value.splice(formIndex, 1)
deletedFormHash.value = deletedHash

if (deletedHash === routeHash.value && route.name !== 'root') {
router.push({ name: 'root' })
// Navigate to root without triggering route guards
router.replace({ name: 'root' })
}
}

// Reset deletedFormHash when navigating away from the deleted form
watch(
() => route.name,
(newRouteName) => {
if (newRouteName === 'root') {
deletedFormHash.value = null
}
},
)

const onLastUpdatedByEventBus = (id) => {
const formIndex = forms.value.findIndex((form) => form.id === id)
if (formIndex !== -1) {
Expand Down
Loading