Skip to content

Commit eef0fac

Browse files
committed
fix(files_version): mtime confusion on milliseconds
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent ed6c2cf commit eef0fac

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

apps/files_versions/src/views/FilesVersionsSidebarTab.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const loading = ref(false)
7373
const showVersionLabelForm = ref(false)
7474
const editedVersion = ref<Version | null>(null)
7575
76-
const currentVersionMtime = computed(() => props.node?.mtime?.getTime() ?? 0)
76+
const currentVersionMtime = computed(() => Math.floor(new Date(props.node?.mtime?.getTime() ?? 0).getTime() / 1000) * 1000)
7777
7878
/**
7979
* Order versions by mtime.
@@ -130,6 +130,7 @@ const canCompare = computed(() => {
130130
// When either the current node to show or its mtime changes we need to refetch the versions
131131
// When the id changed we immediately show changes
132132
watch(() => props.node.id, loadVersions, { immediate: true })
133+
133134
// On mtime changes we debounce to prevent too many requests.
134135
watchDebounced(currentVersionMtime, loadVersions, { debounce: 600 })
135136
@@ -139,7 +140,10 @@ watchDebounced(currentVersionMtime, loadVersions, { debounce: 600 })
139140
async function loadVersions() {
140141
try {
141142
loading.value = true
142-
versions.value = await fetchVersions(props.node)
143+
// normalize the node`s mtime first – server does not report milliseconds, they are all 0
144+
let normalizedNode = props.node
145+
normalizedNode.mtime = new Date(Math.floor((props.node?.mtime?.getTime() ?? 0) / 1000) * 1000)
146+
versions.value = await fetchVersions(normalizedNode)
143147
} finally {
144148
loading.value = false
145149
}

0 commit comments

Comments
 (0)