From 4bf9a32e8bf3e7cd8a7253d5a451640a994b36b3 Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Tue, 12 Nov 2024 11:30:13 +0100 Subject: [PATCH] fix(files): ensure valid mtime and fallback to crtime if defined Signed-off-by: skjnldsv Signed-off-by: nextcloud-command --- apps/files/src/components/FileEntry.vue | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue index e93b8882be005..dfdecb3061b80 100644 --- a/apps/files/src/components/FileEntry.vue +++ b/apps/files/src/components/FileEntry.vue @@ -84,7 +84,8 @@ class="files-list__row-mtime" data-cy-files-list-row-mtime @click="openDetailsIfAvailable"> - + + {{ t('files', 'Unknown date') }} @@ -221,6 +222,7 @@ export default defineComponent({ color: `color-mix(in srgb, var(--color-main-text) ${ratio}%, var(--color-text-maxcontrast))`, } }, + mtimeOpacity() { const maxOpacityTime = 31 * 24 * 60 * 60 * 1000 // 31 days @@ -238,6 +240,20 @@ export default defineComponent({ color: `color-mix(in srgb, var(--color-main-text) ${ratio}%, var(--color-text-maxcontrast))`, } }, + + mtime() { + // If the mtime is not a valid date, return it as is + if (this.source.mtime && !isNaN(this.source.mtime.getDate())) { + return this.source.mtime + } + + if (this.source.crtime && !isNaN(this.source.crtime.getDate())) { + return this.source.crtime + } + + return null + }, + mtimeTitle() { if (this.source.mtime) { return moment(this.source.mtime).format('LLL')