Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion apps/files_versions/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ export async function restoreVersion(version: Version) {
*/
function formatVersion(version: Required<FileStat>, node: INode): Version {
const mtime = Date.parse(version.lastmod)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What format is lastmod is it the timestamp or a ISO time string?
Because if its the timestamp then we can simplify your "normalization" by just divide by 1000 and floor without need to create a date object again.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is a string, that comes from webdav. That should be d:getlastmodified and hence a date time string like Monday, 12-Jan-98 09:25:56 GMT – I did not double check again.

// server timestamps are seconds-based, we have to nullify the milliseconds
const nodeNormalizedMtime = new Date(Math.floor((node.mtime?.getTime() ?? 0) / 1000) * 1000)

let previewUrl: string
if (mtime === node.mtime?.getTime()) { // Version is the current one
if (mtime === nodeNormalizedMtime.getTime()) { // Version is the current one
previewUrl = generateUrl('/core/preview?fileId={fileId}&c={fileEtag}&x=250&y=250&forceIcon=0&a=0&forceIcon=1&mimeFallback=1', {
fileId: node.id,
fileEtag: node.attributes.etag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const loading = ref(false)
const showVersionLabelForm = ref(false)
const editedVersion = ref<Version | null>(null)

const currentVersionMtime = computed(() => props.node?.mtime?.getTime() ?? 0)
const currentVersionMtime = computed(() => Math.floor(new Date(props.node?.mtime?.getTime() ?? 0).getTime() / 1000) * 1000)

/**
* Order versions by mtime.
Expand Down
26 changes: 26 additions & 0 deletions dist/FilesVersionsSidebarTab-CyMuDS8e.chunk.mjs

Large diffs are not rendered by default.

Large diffs are not rendered by default.

26 changes: 0 additions & 26 deletions dist/FilesVersionsSidebarTab-DW6NsP0F.chunk.mjs

This file was deleted.

4 changes: 2 additions & 2 deletions dist/files_versions-sidebar-tab.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=[window.OC.filePath('', '', 'dist/FilesVersionsSidebarTab-DW6NsP0F.chunk.mjs'),window.OC.filePath('', '', 'dist/index-DL1yHC1K-C7Mzn6Sf.chunk.mjs'),window.OC.filePath('', '', 'dist/Web-4aXjob9I.chunk.mjs'),window.OC.filePath('', '', 'dist/public-C1mLBHT3.chunk.mjs'),window.OC.filePath('', '', 'dist/index-K8P_Ih2p.chunk.mjs'),window.OC.filePath('', '', 'dist/NcModal-DUWLRm_F-QkQsKf6T.chunk.mjs'),window.OC.filePath('', '', 'dist/logger-D3RVzcfQ-B4AClKUz.chunk.mjs'),window.OC.filePath('', '', 'dist/createElementId-DhjFt1I9-DRuXW_VL.chunk.mjs'),window.OC.filePath('', '', 'dist/translation-DoG5ZELJ-CWq5lJfa.chunk.mjs'),window.OC.filePath('', '', 'dist/index-BRcsAfAF.chunk.mjs'),window.OC.filePath('', '', 'dist/common-createElementId-DhjFt1I9-C_oBIsvc.chunk.css'),window.OC.filePath('', '', 'dist/common-logger-D3RVzcfQ-BE3lcFW4.chunk.css'),window.OC.filePath('', '', 'dist/common-NcModal-DUWLRm_F-BTyrtOa8.chunk.css'),window.OC.filePath('', '', 'dist/TrashCanOutline-B_y8GQFM.chunk.mjs'),window.OC.filePath('', '', 'dist/common-TrashCanOutline-BYHcrfvW.chunk.css'),window.OC.filePath('', '', 'dist/common-index-DYA_tnKg.chunk.css'),window.OC.filePath('', '', 'dist/mdi-CqCJTJVx.chunk.mjs'),window.OC.filePath('', '', 'dist/common-mdi-BWNFKLbC.chunk.css'),window.OC.filePath('', '', 'dist/index-CcocvZla.chunk.mjs'),window.OC.filePath('', '', 'dist/externalStorageUtils-By5BlBrW.chunk.mjs'),window.OC.filePath('', '', 'dist/util-BcZIBtn7.chunk.mjs'),window.OC.filePath('', '', 'dist/PencilOutline-lHxGrdve.chunk.mjs'),window.OC.filePath('', '', 'dist/common-PencilOutline-B3DMd8SU.chunk.css'),window.OC.filePath('', '', 'dist/NcDateTime.vue_vue_type_script_setup_true_lang-BJuPH7S7-CqC8WnLz.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcDateTime-b9UhLDij.chunk.css'),window.OC.filePath('', '', 'dist/NcAvatar-M3-CbKbq-CGIiXkGL.chunk.mjs'),window.OC.filePath('', '', 'dist/index-C7qAK2mh.chunk.mjs'),window.OC.filePath('', '', 'dist/ArrowRight-3hdWfV3g.chunk.mjs'),window.OC.filePath('', '', 'dist/common-ArrowRight-vZpQWIqF.chunk.css'),window.OC.filePath('', '', 'dist/colors-BDeMBgfq-FBweF9ga.chunk.mjs'),window.OC.filePath('', '', 'dist/NcUserStatusIcon-DsviB2Cr-C0S9RnqH.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcUserStatusIcon-DsviB2Cr-Bq_6hmXG.chunk.css'),window.OC.filePath('', '', 'dist/common-NcAvatar-M3-CbKbq-DTVmI7NO.chunk.css'),window.OC.filePath('', '', 'dist/TrayArrowDown-DZjmYF5a.chunk.mjs'),window.OC.filePath('', '', 'dist/common-TrayArrowDown-CaC9_ffV.chunk.css'),window.OC.filePath('', '', 'dist/NcTextField.vue_vue_type_script_setup_true_lang-BQHjkK8r-BB2fhdke.chunk.mjs'),window.OC.filePath('', '', 'dist/NcInputField-B1bGxYHt-BOHBVCPq.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcInputField-B1bGxYHt-BYHxARP-.chunk.css'),window.OC.filePath('', '', 'dist/dav-BdED5k8Z.chunk.mjs'),window.OC.filePath('', '', 'dist/index-DAXcszDE.chunk.mjs'),window.OC.filePath('', '', 'dist/index-BWlXKV4T.chunk.mjs'),window.OC.filePath('', '', 'dist/files_versions-FilesVersionsSidebarTab-Cjl2hr1y.chunk.css')])))=>i.map(i=>d[i]);
import{d as i,a as r,_ as e}from"./Web-4aXjob9I.chunk.mjs";import{r as t}from"./index-CcocvZla.chunk.mjs";import{t as m}from"./translation-DoG5ZELJ-CWq5lJfa.chunk.mjs";import{i as n}from"./public-C1mLBHT3.chunk.mjs";import{F as a}from"./externalStorageUtils-By5BlBrW.chunk.mjs";import"./index-BRcsAfAF.chunk.mjs";import"./util-BcZIBtn7.chunk.mjs";const d='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-backup-restore" viewBox="0 0 24 24"><path d="M12,3A9,9 0 0,0 3,12H0L4,16L8,12H5A7,7 0 0,1 12,5A7,7 0 0,1 19,12A7,7 0 0,1 12,19C10.5,19 9.09,18.5 7.94,17.7L6.5,19.14C8.04,20.3 9.94,21 12,21A9,9 0 0,0 21,12A9,9 0 0,0 12,3M14,12A2,2 0 0,0 12,10A2,2 0 0,0 10,12A2,2 0 0,0 12,14A2,2 0 0,0 14,12Z" /></svg>',s="files-versions_sidebar-tab";t({id:"files_versions",tagName:s,order:90,displayName:m("files_versions","Versions"),iconSvgInline:d,enabled({node:o}){return!(n()||o.type!==a.File)},async onInit(){const o=r(()=>e(()=>import("./FilesVersionsSidebarTab-DW6NsP0F.chunk.mjs"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41]),import.meta.url));window.customElements.define(s,i(o,{shadowRoot:!1}))}});
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=[window.OC.filePath('', '', 'dist/FilesVersionsSidebarTab-CyMuDS8e.chunk.mjs'),window.OC.filePath('', '', 'dist/index-DL1yHC1K-C7Mzn6Sf.chunk.mjs'),window.OC.filePath('', '', 'dist/Web-4aXjob9I.chunk.mjs'),window.OC.filePath('', '', 'dist/public-C1mLBHT3.chunk.mjs'),window.OC.filePath('', '', 'dist/index-K8P_Ih2p.chunk.mjs'),window.OC.filePath('', '', 'dist/NcModal-DUWLRm_F-QkQsKf6T.chunk.mjs'),window.OC.filePath('', '', 'dist/logger-D3RVzcfQ-B4AClKUz.chunk.mjs'),window.OC.filePath('', '', 'dist/createElementId-DhjFt1I9-DRuXW_VL.chunk.mjs'),window.OC.filePath('', '', 'dist/translation-DoG5ZELJ-CWq5lJfa.chunk.mjs'),window.OC.filePath('', '', 'dist/index-BRcsAfAF.chunk.mjs'),window.OC.filePath('', '', 'dist/common-createElementId-DhjFt1I9-C_oBIsvc.chunk.css'),window.OC.filePath('', '', 'dist/common-logger-D3RVzcfQ-BE3lcFW4.chunk.css'),window.OC.filePath('', '', 'dist/common-NcModal-DUWLRm_F-BTyrtOa8.chunk.css'),window.OC.filePath('', '', 'dist/TrashCanOutline-B_y8GQFM.chunk.mjs'),window.OC.filePath('', '', 'dist/common-TrashCanOutline-BYHcrfvW.chunk.css'),window.OC.filePath('', '', 'dist/common-index-DYA_tnKg.chunk.css'),window.OC.filePath('', '', 'dist/mdi-CqCJTJVx.chunk.mjs'),window.OC.filePath('', '', 'dist/common-mdi-BWNFKLbC.chunk.css'),window.OC.filePath('', '', 'dist/index-CcocvZla.chunk.mjs'),window.OC.filePath('', '', 'dist/externalStorageUtils-By5BlBrW.chunk.mjs'),window.OC.filePath('', '', 'dist/util-BcZIBtn7.chunk.mjs'),window.OC.filePath('', '', 'dist/PencilOutline-lHxGrdve.chunk.mjs'),window.OC.filePath('', '', 'dist/common-PencilOutline-B3DMd8SU.chunk.css'),window.OC.filePath('', '', 'dist/NcDateTime.vue_vue_type_script_setup_true_lang-BJuPH7S7-CqC8WnLz.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcDateTime-b9UhLDij.chunk.css'),window.OC.filePath('', '', 'dist/NcAvatar-M3-CbKbq-CGIiXkGL.chunk.mjs'),window.OC.filePath('', '', 'dist/index-C7qAK2mh.chunk.mjs'),window.OC.filePath('', '', 'dist/ArrowRight-3hdWfV3g.chunk.mjs'),window.OC.filePath('', '', 'dist/common-ArrowRight-vZpQWIqF.chunk.css'),window.OC.filePath('', '', 'dist/colors-BDeMBgfq-FBweF9ga.chunk.mjs'),window.OC.filePath('', '', 'dist/NcUserStatusIcon-DsviB2Cr-C0S9RnqH.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcUserStatusIcon-DsviB2Cr-Bq_6hmXG.chunk.css'),window.OC.filePath('', '', 'dist/common-NcAvatar-M3-CbKbq-DTVmI7NO.chunk.css'),window.OC.filePath('', '', 'dist/TrayArrowDown-DZjmYF5a.chunk.mjs'),window.OC.filePath('', '', 'dist/common-TrayArrowDown-CaC9_ffV.chunk.css'),window.OC.filePath('', '', 'dist/NcTextField.vue_vue_type_script_setup_true_lang-BQHjkK8r-BB2fhdke.chunk.mjs'),window.OC.filePath('', '', 'dist/NcInputField-B1bGxYHt-BOHBVCPq.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcInputField-B1bGxYHt-BYHxARP-.chunk.css'),window.OC.filePath('', '', 'dist/dav-BdED5k8Z.chunk.mjs'),window.OC.filePath('', '', 'dist/index-DAXcszDE.chunk.mjs'),window.OC.filePath('', '', 'dist/index-BWlXKV4T.chunk.mjs'),window.OC.filePath('', '', 'dist/files_versions-FilesVersionsSidebarTab-Cjl2hr1y.chunk.css')])))=>i.map(i=>d[i]);
import{d as i,a as r,_ as e}from"./Web-4aXjob9I.chunk.mjs";import{r as t}from"./index-CcocvZla.chunk.mjs";import{t as m}from"./translation-DoG5ZELJ-CWq5lJfa.chunk.mjs";import{i as n}from"./public-C1mLBHT3.chunk.mjs";import{F as a}from"./externalStorageUtils-By5BlBrW.chunk.mjs";import"./index-BRcsAfAF.chunk.mjs";import"./util-BcZIBtn7.chunk.mjs";const d='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-backup-restore" viewBox="0 0 24 24"><path d="M12,3A9,9 0 0,0 3,12H0L4,16L8,12H5A7,7 0 0,1 12,5A7,7 0 0,1 19,12A7,7 0 0,1 12,19C10.5,19 9.09,18.5 7.94,17.7L6.5,19.14C8.04,20.3 9.94,21 12,21A9,9 0 0,0 21,12A9,9 0 0,0 12,3M14,12A2,2 0 0,0 12,10A2,2 0 0,0 10,12A2,2 0 0,0 12,14A2,2 0 0,0 14,12Z" /></svg>',s="files-versions_sidebar-tab";t({id:"files_versions",tagName:s,order:90,displayName:m("files_versions","Versions"),iconSvgInline:d,enabled({node:o}){return!(n()||o.type!==a.File)},async onInit(){const o=r(()=>e(()=>import("./FilesVersionsSidebarTab-CyMuDS8e.chunk.mjs"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41]),import.meta.url));window.customElements.define(s,i(o,{shadowRoot:!1}))}});
//# sourceMappingURL=files_versions-sidebar-tab.mjs.map
Loading