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)
})
Comment on lines +113 to +119
Copy link
Contributor

Choose a reason for hiding this comment

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

This should no longer be needed on Nextcloud 33+.
As soon as the the current open node was updated, the sidebar receives a new context and passes this to the sidebar tab.
Meaning when you emit files:node:updated inside your app (e.g. text) then the files app will update the node in the store, propagate this to the sidebar and the sidebar tab should update the content.

The watch of the node prop should be enough, if not then this is a bug in the files app and need to be fixed there.


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

/**
Expand Down