Skip to content

Commit

Permalink
Merge pull request #1155 from nextcloud-libraries/fix/drop-moment
Browse files Browse the repository at this point in the history
fix: Drop dependency on moment.js
  • Loading branch information
susnux authored Apr 13, 2024
2 parents 31afc52 + ecfbbe4 commit b761611
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 34 deletions.
39 changes: 29 additions & 10 deletions lib/components/NodesPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
<!-- Description -->
<span class="node-picker__desc">
<span class="node-picker__name">{{ t('New version') }}</span>
<span class="node-picker__mtime">{{ lastModified(incoming) }}</span>
<NcDateTime v-if="incomingLastModified"
:timestamp="incomingLastModified"
:relative-time="false"
:format="{ timeStyle: 'short', dateStyle: 'medium' }"
class="node-picker__mtime" />
<span v-else class="node-picker__mtime">
{{ t('Last modified date unknown') }}
</span>
<span class="node-picker__size">{{ size(incoming) }}</span>
</span>
</span>
Expand All @@ -48,7 +55,14 @@
<!-- Description -->
<span class="node-picker__desc">
<span class="node-picker__name">{{ t('Existing version') }}</span>
<span class="node-picker__mtime">{{ lastModified(existing) }}</span>
<NcDateTime v-if="existingLastModified"
:timestamp="existingLastModified"
:relative-time="false"
:format="{ timeStyle: 'short', dateStyle: 'medium' }"
class="node-picker__mtime" />
<span v-else class="node-picker__mtime">
{{ t('Last modified date unknown') }}
</span>
<span class="node-picker__size">{{ size(existing) }}</span>
</span>
</span>
Expand All @@ -62,10 +76,10 @@ import type { PropType } from 'vue'
import { defineComponent } from 'vue'
import { formatFileSize, FileType, Node } from '@nextcloud/files'
import { generateUrl } from '@nextcloud/router'
import moment from '@nextcloud/moment'
import FileSvg from 'vue-material-design-icons/File.vue'
import FolderSvg from 'vue-material-design-icons/Folder.vue'
import NcDateTime from '@nextcloud/vue/dist/Components/NcDateTime.js'
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import { t } from '../utils/l10n.ts'
Expand All @@ -79,6 +93,7 @@ export default defineComponent({
FileSvg,
FolderSvg,
NcCheckboxRadioSwitch,
NcDateTime,
},
props: {
Expand All @@ -102,7 +117,7 @@ export default defineComponent({
data() {
return {
asyncPreview: null,
asyncPreview: null as string | null,
}
},
Expand All @@ -127,17 +142,21 @@ export default defineComponent({
existingPreview() {
return this.previewUrl(this.existing)
},
incomingLastModified() {
return this.lastModified(this.incoming)
},
existingLastModified() {
return this.lastModified(this.existing)
},
},
methods: {
lastModified(node: File|Node): string {
lastModified(node: File|Node): Date | null {
const lastModified = node instanceof File
? new Date(node.lastModified)
: node.mtime
if (lastModified) {
return moment(lastModified).format('LLL')
}
return t('Last modified date unknown')
return lastModified ?? null
},
size(node: File|Node): string {
if (node.size) {
Expand All @@ -147,7 +166,7 @@ export default defineComponent({
},
previewUrl(node: File|Node) {
if (node instanceof File) {
this.previewImage(node).then((url: string) => {
this.previewImage(node).then((url: string | null) => {
this.asyncPreview = url
})
return
Expand Down
23 changes: 0 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"@nextcloud/files": "^3.1.1",
"@nextcloud/l10n": "^2.2.0",
"@nextcloud/logger": "^2.7.0",
"@nextcloud/moment": "^1.3.1",
"@nextcloud/paths": "^2.1.0",
"@nextcloud/router": "^3.0.0",
"axios": "^1.6.8",
Expand Down

0 comments on commit b761611

Please sign in to comment.