refacto: revert to moment and fix to old version

This commit is contained in:
Michel Roux 2024-01-11 20:58:15 +01:00
parent e478372b47
commit 9b932437fc
5 changed files with 42 additions and 22 deletions

46
package-lock.json generated
View File

@ -13,9 +13,9 @@
"@nextcloud/dialogs": "^5.0.3", "@nextcloud/dialogs": "^5.0.3",
"@nextcloud/initial-state": "^2.1.0", "@nextcloud/initial-state": "^2.1.0",
"@nextcloud/l10n": "^2.2.0", "@nextcloud/l10n": "^2.2.0",
"@nextcloud/moment": "1.2.2",
"@nextcloud/router": "^2.2.0", "@nextcloud/router": "^2.2.0",
"@nextcloud/vue": "^8.4.0", "@nextcloud/vue": "^8.4.0",
"date-fns": "^3.2.0",
"vue": "^2", "vue": "^2",
"vue-material-design-icons": "^5.2.0", "vue-material-design-icons": "^5.2.0",
"vue-router": "^3", "vue-router": "^3",
@ -3221,6 +3221,22 @@
"npm": "^9.0.0" "npm": "^9.0.0"
} }
}, },
"node_modules/@nextcloud/moment": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/@nextcloud/moment/-/moment-1.2.2.tgz",
"integrity": "sha512-66jJJurd4JdqqlGIpqfxMWOvpG7i6dMibkNCPcpe8i+C+bGSFRMxMe74m1abehcaysj164is4juiT2ikVbZ4yg==",
"dependencies": {
"@nextcloud/l10n": "^2.2.0",
"core-js": "^3.21.1",
"jed": "^1.1.1",
"moment": "^2.29.2",
"node-gettext": "^3.0.0"
},
"engines": {
"node": "^20.0.0",
"npm": "^9.0.0"
}
},
"node_modules/@nextcloud/paths": { "node_modules/@nextcloud/paths": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/@nextcloud/paths/-/paths-2.1.0.tgz", "resolved": "https://registry.npmjs.org/@nextcloud/paths/-/paths-2.1.0.tgz",
@ -6742,15 +6758,6 @@
"node": ">= 12" "node": ">= 12"
} }
}, },
"node_modules/date-fns": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-3.2.0.tgz",
"integrity": "sha512-E4KWKavANzeuusPi0jUjpuI22SURAznGkx7eZV+4i6x2A+IZxAMcajgkvuDAU1bg40+xuhW1zRdVIIM/4khuIg==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/kossnocorp"
}
},
"node_modules/date-format-parse": { "node_modules/date-format-parse": {
"version": "0.2.7", "version": "0.2.7",
"resolved": "https://registry.npmjs.org/date-format-parse/-/date-format-parse-0.2.7.tgz", "resolved": "https://registry.npmjs.org/date-format-parse/-/date-format-parse-0.2.7.tgz",
@ -10504,6 +10511,11 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/jed": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/jed/-/jed-1.1.1.tgz",
"integrity": "sha512-z35ZSEcXHxLW4yumw0dF6L464NT36vmx3wxJw8MDpraBcWuNVgUPZgPJKcu1HekNgwlMFNqol7i/IpSbjhqwqA=="
},
"node_modules/jest": { "node_modules/jest": {
"version": "29.7.0", "version": "29.7.0",
"resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz",
@ -13157,6 +13169,14 @@
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/moment": {
"version": "2.30.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz",
"integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==",
"engines": {
"node": "*"
}
},
"node_modules/ms": { "node_modules/ms": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@ -15081,9 +15101,9 @@
"peer": true "peer": true
}, },
"node_modules/safe-regex-test": { "node_modules/safe-regex-test": {
"version": "1.0.1", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.1.tgz", "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.2.tgz",
"integrity": "sha512-Y5NejJTTliTyY4H7sipGqY+RX5P87i3F7c4Rcepy72nq+mNLhIsD0W4c7kEmduMDQCSqtPsXPlSTsFhh2LQv+g==", "integrity": "sha512-83S9w6eFq12BBIJYvjMux6/dkirb8+4zJRA9cxNBVb7Wq5fJBW+Xze48WqR8pxua7bDuAaaAxtVVd4Idjp1dBQ==",
"dev": true, "dev": true,
"peer": true, "peer": true,
"dependencies": { "dependencies": {

View File

@ -22,9 +22,9 @@
"@nextcloud/dialogs": "^5.0.3", "@nextcloud/dialogs": "^5.0.3",
"@nextcloud/initial-state": "^2.1.0", "@nextcloud/initial-state": "^2.1.0",
"@nextcloud/l10n": "^2.2.0", "@nextcloud/l10n": "^2.2.0",
"@nextcloud/moment": "1.2.2",
"@nextcloud/router": "^2.2.0", "@nextcloud/router": "^2.2.0",
"@nextcloud/vue": "^8.4.0", "@nextcloud/vue": "^8.4.0",
"date-fns": "^3.2.0",
"vue": "^2", "vue": "^2",
"vue-material-design-icons": "^5.2.0", "vue-material-design-icons": "^5.2.0",
"vue-router": "^3", "vue-router": "^3",

View File

@ -4,7 +4,7 @@
<AdaptativeList v-if="!loading"> <AdaptativeList v-if="!loading">
<NcListItem v-for="feed in feeds" <NcListItem v-for="feed in feeds"
:key="feed.link" :key="feed.link"
:details="formatDistanceToNow(new Date(feed.fetchedAtUnix*1000))" :details="moment(feed.fetchedAtUnix*1000).fromNow()"
:name="feed.title" :name="feed.title"
:to="toUrl(feed.link)"> :to="toUrl(feed.link)">
<template #icon> <template #icon>
@ -26,8 +26,8 @@ import AdaptativeList from '../Atoms/AdaptativeList.vue'
import Loading from '../Atoms/Loading.vue' import Loading from '../Atoms/Loading.vue'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { debounce } from '../../utils/debounce.js' import { debounce } from '../../utils/debounce.js'
import { formatDistanceToNow } from 'date-fns'
import { generateUrl } from '@nextcloud/router' import { generateUrl } from '@nextcloud/router'
import moment from '@nextcloud/moment'
import { showError } from '@nextcloud/dialogs' import { showError } from '@nextcloud/dialogs'
export default { export default {
@ -56,7 +56,7 @@ export default {
}, },
}, },
methods: { methods: {
formatDistanceToNow, moment,
search: debounce(async function value() { search: debounce(async function value() {
try { try {
this.loading = true this.loading = true

View File

@ -6,7 +6,7 @@
:key="episode.guid" :key="episode.guid"
:active="isCurrentEpisode(episode)" :active="isCurrentEpisode(episode)"
:class="episode.action && episode.action.position >= episode.action.total ? 'ended': ''" :class="episode.action && episode.action.position >= episode.action.total ? 'ended': ''"
:details="formatDistanceToNow(new Date(episode.pubDate.date))" :details="moment(episode.pubDate.date).fromNow()"
:force-display-actions="true" :force-display-actions="true"
:name="episode.name" :name="episode.name"
:title="episode.description" :title="episode.description"
@ -55,9 +55,9 @@ import Modal from './Modal.vue'
import PlayButton from 'vue-material-design-icons/Play.vue' import PlayButton from 'vue-material-design-icons/Play.vue'
import StopButton from 'vue-material-design-icons/Stop.vue' import StopButton from 'vue-material-design-icons/Stop.vue'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { formatDistanceToNow } from 'date-fns'
import { formatTimer } from '../../utils/time.js' import { formatTimer } from '../../utils/time.js'
import { generateUrl } from '@nextcloud/router' import { generateUrl } from '@nextcloud/router'
import moment from '@nextcloud/moment'
import { showError } from '@nextcloud/dialogs' import { showError } from '@nextcloud/dialogs'
export default { export default {
@ -102,7 +102,7 @@ export default {
}, },
methods: { methods: {
formatTimer, formatTimer,
formatDistanceToNow, moment,
isCurrentEpisode(episode) { isCurrentEpisode(episode) {
return this.currentEpisode && this.currentEpisode.url === episode.url return this.currentEpisode && this.currentEpisode.url === episode.url
}, },

View File

@ -1,6 +1,6 @@
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { format } from 'date-fns'
import { generateUrl } from '@nextcloud/router' import { generateUrl } from '@nextcloud/router'
import moment from '@nextcloud/moment'
import router from '../router.js' import router from '../router.js'
import store from './main.js' import store from './main.js'
@ -93,7 +93,7 @@ export const player = {
episode: context.state.episode.url, episode: context.state.episode.url,
guid: context.state.episode.guid, guid: context.state.episode.guid,
action: 'play', action: 'play',
timestamp: format(new Date(), 'yyyy-MM-dd\'T\'HH:mm:ss'), timestamp: moment().format('YYYY-MM-DD[T]HH:mm:ss'),
started: Math.round(context.state.action ? context.state.action.started : 0), started: Math.round(context.state.action ? context.state.action.started : 0),
position: Math.round(audio.currentTime), position: Math.round(audio.currentTime),
total: Math.round(audio.duration), total: Math.round(audio.duration),