typescript #149 #152

Merged
Xefir merged 8 commits from typescript into main 2024-09-14 15:26:18 +00:00
7 changed files with 65 additions and 65 deletions
Showing only changes of commit 23280d68b9 - Show all commits

View File

@ -1,7 +1,7 @@
module.exports = { module.exports = {
extends: [ extends: [
'@nextcloud', '@nextcloud',
'@vue/eslint-config-typescript', '@vue/eslint-config-typescript/recommended',
'plugin:pinia/recommended', 'plugin:pinia/recommended',
'plugin:prettier/recommended', 'plugin:prettier/recommended',
], ],

56
package-lock.json generated
View File

@ -15,7 +15,6 @@
"@nextcloud/vue": "9.0.0-alpha.5", "@nextcloud/vue": "9.0.0-alpha.5",
"dompurify": "^3.1.6", "dompurify": "^3.1.6",
"linkify-html": "^4.1.3", "linkify-html": "^4.1.3",
"petite-utils": "^0.0.5-3",
"pinia": "^2.2.2", "pinia": "^2.2.2",
"toastify-js": "^1.12.0", "toastify-js": "^1.12.0",
"vite": "^5.4.5", "vite": "^5.4.5",
@ -36,7 +35,7 @@
"eslint-plugin-pinia": "^0.4.1", "eslint-plugin-pinia": "^0.4.1",
"eslint-plugin-prettier": "^5.2.1", "eslint-plugin-prettier": "^5.2.1",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "5.5.4", "typescript": "5.5",
"vue-eslint-parser": "^9.4.3", "vue-eslint-parser": "^9.4.3",
"vue-tsc": "^2.1.6" "vue-tsc": "^2.1.6"
} }
@ -2272,9 +2271,9 @@
"integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g=="
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.5.4", "version": "22.5.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.4.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.5.tgz",
"integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==", "integrity": "sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==",
"devOptional": true, "devOptional": true,
"peer": true, "peer": true,
"dependencies": { "dependencies": {
@ -2550,29 +2549,29 @@
} }
}, },
"node_modules/@volar/typescript": { "node_modules/@volar/typescript": {
"version": "2.4.4", "version": "2.4.5",
"resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-2.4.4.tgz", "resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-2.4.5.tgz",
"integrity": "sha512-QQMQRVj0fVHJ3XdRKiS1LclhG0VBXdFYlyuHRQF/xLk2PuJuHNWP26MDZNvEVCvnyUQuUQhIAfylwY5TGPgc6w==", "integrity": "sha512-mcT1mHvLljAEtHviVcBuOyAwwMKz1ibXTi5uYtP/pf4XxoAzpdkQ+Br2IC0NPCvLCbjPZmbf3I0udndkfB1CDg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@volar/language-core": "2.4.4", "@volar/language-core": "2.4.5",
"path-browserify": "^1.0.1", "path-browserify": "^1.0.1",
"vscode-uri": "^3.0.8" "vscode-uri": "^3.0.8"
} }
}, },
"node_modules/@volar/typescript/node_modules/@volar/language-core": { "node_modules/@volar/typescript/node_modules/@volar/language-core": {
"version": "2.4.4", "version": "2.4.5",
"resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.4.tgz", "resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.5.tgz",
"integrity": "sha512-kO9k4kTLfxpg+6lq7/KAIv3m2d62IHuCL6GbVgYZTpfKvIGoAIlDxK7pFcB/eczN2+ydg/vnyaeZ6SGyZrJw2w==", "integrity": "sha512-F4tA0DCO5Q1F5mScHmca0umsi2ufKULAnMOVBfMsZdT4myhVl4WdKRwCaKcfOkIEuyrAVvtq1ESBdZ+rSyLVww==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@volar/source-map": "2.4.4" "@volar/source-map": "2.4.5"
} }
}, },
"node_modules/@volar/typescript/node_modules/@volar/source-map": { "node_modules/@volar/typescript/node_modules/@volar/source-map": {
"version": "2.4.4", "version": "2.4.5",
"resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.4.tgz", "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.5.tgz",
"integrity": "sha512-xG3PZqOP2haG8XG4Pg3PD1UGDAdqZg24Ru8c/qYjYAnmcj6GBR64mstx+bZux5QOyRaJK+/lNM/RnpvBD3489g==", "integrity": "sha512-varwD7RaKE2J/Z+Zu6j3mNNJbNT394qIxXwdvz/4ao/vxOfyClZpSDtLKkwWmecinkOVos5+PWkWraelfMLfpw==",
"dev": true "dev": true
}, },
"node_modules/@vue/babel-helper-vue-transform-on": { "node_modules/@vue/babel-helper-vue-transform-on": {
@ -4401,9 +4400,9 @@
} }
}, },
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.5.22", "version": "1.5.23",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.22.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.23.tgz",
"integrity": "sha512-tKYm5YHPU1djz0O+CGJ+oJIvimtsCcwR2Z9w7Skh08lUdyzXY5djods3q+z2JkWdb7tCcmM//eVavSRAiaPRNg==" "integrity": "sha512-mBhODedOXg4v5QWwl21DjM5amzjmI1zw9EPrPK/5Wx7C8jt33bpZNrC7OhHUG3pxRtbLpr3W2dXT+Ph1SsfRZA=="
}, },
"node_modules/elliptic": { "node_modules/elliptic": {
"version": "6.5.7", "version": "6.5.7",
@ -8788,11 +8787,6 @@
"resolved": "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-1.0.0.tgz", "resolved": "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-1.0.0.tgz",
"integrity": "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==" "integrity": "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA=="
}, },
"node_modules/petite-utils": {
"version": "0.0.5-3",
"resolved": "https://registry.npmjs.org/petite-utils/-/petite-utils-0.0.5-3.tgz",
"integrity": "sha512-oeuwgChhxtYMuxyaHzSo8aoix+pjTKBnHlii04uMRhUIaazCCCG4NAkGwdpnvgfdYE2ajVhnARoFtdRujJuUjA=="
},
"node_modules/picocolors": { "node_modules/picocolors": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz",
@ -12038,18 +12032,18 @@
} }
}, },
"node_modules/vue-tsc/node_modules/@volar/language-core": { "node_modules/vue-tsc/node_modules/@volar/language-core": {
"version": "2.4.4", "version": "2.4.5",
"resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.4.tgz", "resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.5.tgz",
"integrity": "sha512-kO9k4kTLfxpg+6lq7/KAIv3m2d62IHuCL6GbVgYZTpfKvIGoAIlDxK7pFcB/eczN2+ydg/vnyaeZ6SGyZrJw2w==", "integrity": "sha512-F4tA0DCO5Q1F5mScHmca0umsi2ufKULAnMOVBfMsZdT4myhVl4WdKRwCaKcfOkIEuyrAVvtq1ESBdZ+rSyLVww==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@volar/source-map": "2.4.4" "@volar/source-map": "2.4.5"
} }
}, },
"node_modules/vue-tsc/node_modules/@volar/source-map": { "node_modules/vue-tsc/node_modules/@volar/source-map": {
"version": "2.4.4", "version": "2.4.5",
"resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.4.tgz", "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.5.tgz",
"integrity": "sha512-xG3PZqOP2haG8XG4Pg3PD1UGDAdqZg24Ru8c/qYjYAnmcj6GBR64mstx+bZux5QOyRaJK+/lNM/RnpvBD3489g==", "integrity": "sha512-varwD7RaKE2J/Z+Zu6j3mNNJbNT394qIxXwdvz/4ao/vxOfyClZpSDtLKkwWmecinkOVos5+PWkWraelfMLfpw==",
"dev": true "dev": true
}, },
"node_modules/vue-tsc/node_modules/@vue/language-core": { "node_modules/vue-tsc/node_modules/@vue/language-core": {

View File

@ -22,7 +22,6 @@
"@nextcloud/vue": "9.0.0-alpha.5", "@nextcloud/vue": "9.0.0-alpha.5",
"dompurify": "^3.1.6", "dompurify": "^3.1.6",
"linkify-html": "^4.1.3", "linkify-html": "^4.1.3",
"petite-utils": "^0.0.5-3",
"pinia": "^2.2.2", "pinia": "^2.2.2",
"toastify-js": "^1.12.0", "toastify-js": "^1.12.0",
"vite": "^5.4.5", "vite": "^5.4.5",
@ -43,7 +42,7 @@
"eslint-plugin-pinia": "^0.4.1", "eslint-plugin-pinia": "^0.4.1",
"eslint-plugin-prettier": "^5.2.1", "eslint-plugin-prettier": "^5.2.1",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "5.5.4", "typescript": "5.5",
"vue-eslint-parser": "^9.4.3", "vue-eslint-parser": "^9.4.3",
"vue-tsc": "^2.1.6" "vue-tsc": "^2.1.6"
}, },

View File

@ -41,7 +41,6 @@ import Loading from '../Atoms/Loading.vue'
import PlusIcon from 'vue-material-design-icons/Plus.vue' import PlusIcon from 'vue-material-design-icons/Plus.vue'
import type { PodcastDataInterface } from '../../utils/types.ts' import type { PodcastDataInterface } from '../../utils/types.ts'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { debounce } from 'petite-utils'
import { formatLocaleDate } from '../../utils/time.ts' import { formatLocaleDate } from '../../utils/time.ts'
import { generateUrl } from '@nextcloud/router' import { generateUrl } from '@nextcloud/router'
import { showError } from '../../utils/toast.ts' import { showError } from '../../utils/toast.ts'
@ -67,36 +66,17 @@ export default {
data: () => ({ data: () => ({
feeds: [] as PodcastDataInterface[], feeds: [] as PodcastDataInterface[],
loading: false, loading: false,
timeout: null as NodeJS.Timeout | null,
}), }),
computed: { computed: {
...mapState(useSubscriptions, ['getSubByUrl']), ...mapState(useSubscriptions, ['getSubByUrl']),
}, },
watch: { watch: {
value() { value() {
const that = this if (this.timeout) {
debounce(async function () { clearTimeout(this.timeout)
try {
that.loading = true
const currentSearch = that.value
const feeds = await axios.get<PodcastDataInterface[]>(
generateUrl('/apps/repod/search?q={value}', {
value: currentSearch,
}),
)
if (currentSearch === that.value) {
that.feeds = [...feeds.data].sort(
(a, b) => b.fetchedAtUnix - a.fetchedAtUnix,
)
} }
} catch (e) { this.timeout = setTimeout(this.search, 200)
console.error(e)
showError(t('repod', 'Could not fetch search results'))
} finally {
if (that.feeds) {
that.loading = false
}
}
}, 200)
}, },
}, },
methods: { methods: {
@ -117,9 +97,31 @@ export default {
console.error(e) console.error(e)
showError(t('repod', 'Error while adding the feed')) showError(t('repod', 'Error while adding the feed'))
} }
this.fetch() this.fetch()
}, },
async search() {
try {
this.loading = true
const currentSearch = this.value
const feeds = await axios.get<PodcastDataInterface[]>(
generateUrl('/apps/repod/search?q={value}', {
value: currentSearch,
}),
)
if (currentSearch === this.value) {
this.feeds = [...feeds.data].sort(
(a, b) => b.fetchedAtUnix - a.fetchedAtUnix,
)
}
} catch (e) {
console.error(e)
showError(t('repod', 'Could not fetch search results'))
} finally {
if (this.feeds) {
this.loading = false
}
}
},
}, },
} }
</script> </script>

View File

@ -91,7 +91,7 @@ export default {
}, },
), ),
) )
this.addFavoriteData(podcastData.data.data) this.addMetadatas(this.url, podcastData.data.data)
} catch (e) { } catch (e) {
this.failed = true this.failed = true
console.error(e) console.error(e)
@ -100,7 +100,7 @@ export default {
} }
}, },
methods: { methods: {
...mapActions(useSubscriptions, ['fetch', 'addFavoriteData', 'setFavorite']), ...mapActions(useSubscriptions, ['fetch', 'addMetadatas', 'setFavorite']),
t, t,
toFeedUrl, toFeedUrl,
async deleteSubscription() { async deleteSubscription() {

View File

@ -6,6 +6,11 @@ export const useSettings = defineStore('settings', {
state: () => { state: () => {
try { try {
const filters = JSON.parse(getCookie('repod.filters') || '{}') || {} const filters = JSON.parse(getCookie('repod.filters') || '{}') || {}
if (!filters.length) {
throw new Error('Empty cookie')
}
return { return {
filters: { filters: {
listened: filters.listened, listened: filters.listened,

View File

@ -34,13 +34,13 @@ export const useSubscriptions = defineStore('subscriptions', {
data: this.subs.find((s) => s.metrics.url === sub.url)?.data, data: this.subs.find((s) => s.metrics.url === sub.url)?.data,
})) }))
}, },
addFavoriteData(data: PodcastDataInterface) { addMetadatas(link: string, data: PodcastDataInterface) {
this.subs = this.subs.map((sub) => this.subs = this.subs.map((sub) =>
sub.metrics.url === data.link ? { ...sub, data } : sub, sub.metrics.url === link ? { ...sub, data } : sub,
) )
}, },
setFavorite(link: string, isFavorite: boolean) { setFavorite(link: string, isFavorite: boolean) {
this.subs.map((sub) => this.subs = this.subs.map((sub) =>
sub.metrics.url === link ? { ...sub, isFavorite } : sub, sub.metrics.url === link ? { ...sub, isFavorite } : sub,
) )