Skip to content

Commit

Permalink
fix(files): ensure valid mtime and fallback to crtime if defined
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <[email protected]>

Signed-off-by: nextcloud-command <[email protected]>
  • Loading branch information
skjnldsv authored and solracsf committed Dec 14, 2024
1 parent 0696ec1 commit 4bf9a32
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
class="files-list__row-mtime"
data-cy-files-list-row-mtime
@click="openDetailsIfAvailable">
<NcDateTime v-if="source.mtime" :timestamp="source.mtime" :ignore-seconds="true" />
<NcDateTime v-if="mtime" :timestamp="mtime" :ignore-seconds="true" />
<span v-else>{{ t('files', 'Unknown date') }}</span>
</td>

<!-- View columns -->
Expand Down Expand Up @@ -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

Expand All @@ -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')
Expand Down

0 comments on commit 4bf9a32

Please sign in to comment.