-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(files_versions): Auto-reload versions tab on file #57843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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' | ||
|
|
@@ -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) | ||
| } | ||
| } | ||
|
|
||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should no longer be needed on Nextcloud 33+. The watch of the |
||
|
|
||
| const currentVersionMtime = computed(() => props.node?.mtime?.getTime() ?? 0) | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:There was a problem hiding this comment.
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.