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
39 changes: 36 additions & 3 deletions apps/files_versions/src/views/FilesVersionsSidebarTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ import type { IFolder, INode, IView } from '@nextcloud/files'
import type { Version } from '../utils/versions.ts'

import { showError, showSuccess } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
import { t } from '@nextcloud/l10n'
import { useIsMobile } from '@nextcloud/vue/composables/useIsMobile'
import { computed, ref, toRef, watch } from 'vue'
import { computed, onBeforeUnmount, onMounted, ref, toRef, watch } from 'vue'
import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
import VersionEntry from '../components/VersionEntry.vue'
import VersionLabelDialog from '../components/VersionLabelDialog.vue'
Expand All @@ -72,19 +72,52 @@ const loading = ref(false)
const showVersionLabelForm = ref(false)
const editedVersion = ref<Version | null>(null)

watch(toRef(() => props.node), async () => {
/**
* Reload versions for the current file
*/
async function reloadVersions() {
if (!props.node) {
return
}

const previousCount = versions.value.length

try {
loading.value = true
versions.value = await fetchVersions(props.node)
console.debug('[FilesVersionsSidebarTab] Reloaded versions:', previousCount, '→', versions.value.length)
} finally {
loading.value = false
}
}

/**
* Handle files:node:updated event to reload versions when the current file is saved
* @param node
*/
function handleNodeUpdated(node: INode) {
// Only reload if this is the currently open file and the tab is active
if (props.active && props.node && node.source === props.node.source) {
console.debug('[FilesVersionsSidebarTab] File saved, reloading versions in 1s')
// Delay to let the server create the new version
setTimeout(() => {
reloadVersions()
}, 1000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now reading this, I'm unsure if the UI_Save post message is the right one as I would expect that once we receive the save success from Collabora we should not need to wait anymore.

Can you check if Action_Save_Resp does get emitted as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I checked with added console logs and definitely did not get Action_Save_Resp:
Screenshot from 2026-01-29 11-01-40

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait be very nice to get rid of the delay though if possible. They are not really reliable.

}
}

watch(toRef(() => props.node), async () => {
await reloadVersions()
}, { immediate: true })

onMounted(() => {
subscribe('files:node:updated', handleNodeUpdated)
})

onBeforeUnmount(() => {
unsubscribe('files:node:updated', handleNodeUpdated)
})

const currentVersionMtime = computed(() => props.node?.mtime?.getTime() ?? 0)

/**
Expand Down