From fc86f62d93afc88a2068dbd79eb76d145ea116f5 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Fri, 13 Sep 2024 16:33:48 +0200 Subject: [PATCH] refactor: :recycle: typescript ok, need tests --- .eslintrc.js => .eslintrc.cjs | 0 lib/Controller/PageController.php | 2 +- package.json | 9 +-- src/App.vue | 2 +- src/components/Discover/Toplist.vue | 4 +- src/components/Feed/Banner.vue | 35 ++++------- src/components/Feed/Episodes.vue | 6 +- src/components/Feed/Favorite.vue | 36 +++++------- src/components/Settings/Export.vue | 4 +- src/components/Settings/Filters.vue | 4 +- src/components/Settings/Import.vue | 13 +++-- src/components/Settings/Rate.vue | 6 +- src/components/Settings/Settings.vue | 2 +- src/components/Settings/Speed.vue | 8 ++- src/components/Sidebar/Subscription.vue | 65 +++++++++------------ src/components/Sidebar/Subscriptions.vue | 21 ++++--- src/store/player.ts | 4 +- src/store/settings.ts | 2 +- src/store/subscriptions.ts | 4 +- src/utils/types.ts | 32 +++++----- src/views/Discover.vue | 6 +- src/views/Feed.vue | 22 +++---- src/views/GPodder.vue | 6 +- src/views/Home.vue | 19 ++++-- stylelint.config.js => stylelint.config.cjs | 0 vite.config.ts | 5 -- 26 files changed, 157 insertions(+), 160 deletions(-) rename .eslintrc.js => .eslintrc.cjs (100%) rename stylelint.config.js => stylelint.config.cjs (100%) diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 100% rename from .eslintrc.js rename to .eslintrc.cjs diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 1788257..ee5b9bb 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -26,7 +26,7 @@ class PageController extends Controller * @NoCSRFRequired */ public function index(): TemplateResponse { - Util::addScript(Application::APP_ID, 'main'); + Util::addScript(Application::APP_ID, Application::APP_ID . '-main'); $csp = new ContentSecurityPolicy(); $csp->addAllowedImageDomain('*'); diff --git a/package.json b/package.json index d5584ab..71b1f19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "repod", "license": "AGPL-3.0-or-later", + "type": "module", "scripts": { "build": "vue-tsc && vite build --mode production", "dev": "vite build --mode development", @@ -11,9 +12,6 @@ "stylelint": "stylelint src/**/*.vue src/**/*.scss src/**/*.css", "stylelint:fix": "stylelint src/**/*.vue src/**/*.scss src/**/*.css --fix" }, - "browserslist": [ - "extends @nextcloud/browserslist-config" - ], "prettier": "@nextcloud/prettier-config", "dependencies": { "@nextcloud/axios": "^2.5.0", @@ -48,5 +46,8 @@ "typescript": "5.5.4", "vue-eslint-parser": "^9.4.3", "vue-tsc": "^2.1.6" - } + }, + "browserslist": [ + "extends @nextcloud/browserslist-config" + ] } diff --git a/src/App.vue b/src/App.vue index 9c0a468..7208e46 100644 --- a/src/App.vue +++ b/src/App.vue @@ -7,7 +7,7 @@ - diff --git a/src/components/Settings/Filters.vue b/src/components/Settings/Filters.vue index d138faf..91c816d 100644 --- a/src/components/Settings/Filters.vue +++ b/src/components/Settings/Filters.vue @@ -39,11 +39,12 @@ - diff --git a/src/components/Settings/Import.vue b/src/components/Settings/Import.vue index 3b15fac..09c33ad 100644 --- a/src/components/Settings/Import.vue +++ b/src/components/Settings/Import.vue @@ -29,12 +29,13 @@ - diff --git a/src/components/Settings/Settings.vue b/src/components/Settings/Settings.vue index 7d07062..816e33e 100644 --- a/src/components/Settings/Settings.vue +++ b/src/components/Settings/Settings.vue @@ -8,7 +8,7 @@ - diff --git a/src/store/player.ts b/src/store/player.ts index f0a4e8e..2076e74 100644 --- a/src/store/player.ts +++ b/src/store/player.ts @@ -1,4 +1,4 @@ -import type { EpisodeInterface } from '../utils/types' +import type { EpisodeActionInterface, EpisodeInterface } from '../utils/types' import axios from '@nextcloud/axios' import { defineStore } from 'pinia' import { formatEpisodeTimestamp } from '../utils/time' @@ -39,7 +39,7 @@ export const usePlayer = defineStore('player', { audio.load() try { - const action = await axios.get( + const action = await axios.get( generateUrl('/apps/repod/episodes/action?url={url}', { url: this.episode.url, }), diff --git a/src/store/settings.ts b/src/store/settings.ts index 8d257de..a3af2ff 100644 --- a/src/store/settings.ts +++ b/src/store/settings.ts @@ -24,7 +24,7 @@ export const useSettings = defineStore('settings', { } }, actions: { - setFilters(filters: FiltersInterface) { + setFilters(filters: Partial) { this.filters = { ...this.filters, ...filters } setCookie('repod.filters', JSON.stringify(this.filters), 365) }, diff --git a/src/store/subscriptions.ts b/src/store/subscriptions.ts index 691a11c..6230291 100644 --- a/src/store/subscriptions.ts +++ b/src/store/subscriptions.ts @@ -1,6 +1,6 @@ import type { + PersonalSettingsMetricsInterface, PodcastDataInterface, - PodcastMetricsInterface, SubscriptionInterface, } from '../utils/types' import { getCookie, setCookie } from '../utils/cookies' @@ -23,7 +23,7 @@ export const useSubscriptions = defineStore('subscriptions', { favorites = JSON.parse(getCookie('repod.favorites') || '[]') || [] } catch {} - const metrics = await axios.get( + const metrics = await axios.get( generateUrl('/apps/gpoddersync/personal_settings/metrics'), ) this.subs = [...metrics.data.subscriptions] diff --git a/src/utils/types.ts b/src/utils/types.ts index f8bd115..bcae018 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -47,23 +47,27 @@ export interface PodcastDataInterface { } export interface PodcastMetricsInterface { - subscriptions: [ - { - url: string - listenedSeconds: number - actionCounts: { - delete: number - download: number - flattr: number - new: number - play: number - } - }, - ] + url: string + listenedSeconds: number + actionCounts: { + delete: number + download: number + flattr: number + new: number + play: number + } } export interface SubscriptionInterface { data?: PodcastDataInterface isFavorite: boolean - metrics: PodcastMetricsInterface['subscriptions'][0] + metrics: PodcastMetricsInterface +} + +export interface PersonalSettingsMetricsInterface { + subscriptions: PodcastMetricsInterface[] +} + +export interface PersonalSettingsPodcastDataInterface { + data: PodcastDataInterface } diff --git a/src/views/Discover.vue b/src/views/Discover.vue index c9113fa..1440016 100644 --- a/src/views/Discover.vue +++ b/src/views/Discover.vue @@ -12,13 +12,14 @@ - diff --git a/src/views/Feed.vue b/src/views/Feed.vue index 209ddcb..4705f73 100644 --- a/src/views/Feed.vue +++ b/src/views/Feed.vue @@ -6,27 +6,23 @@ - + - diff --git a/src/views/GPodder.vue b/src/views/GPodder.vue index adf0f25..b113909 100644 --- a/src/views/GPodder.vue +++ b/src/views/GPodder.vue @@ -13,12 +13,13 @@ - diff --git a/src/views/Home.vue b/src/views/Home.vue index 3d8546b..5158787 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -1,7 +1,7 @@ -
    -
  • - +
      +
    • +
    - diff --git a/stylelint.config.js b/stylelint.config.cjs similarity index 100% rename from stylelint.config.js rename to stylelint.config.cjs diff --git a/vite.config.ts b/vite.config.ts index 7687397..a1e705c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,11 +4,6 @@ import vueDevTools from 'vite-plugin-vue-devtools' const config = defineConfig(({ mode }) => ({ build: { - rollupOptions: { - output: { - entryFileNames: 'js/[name].js', - }, - }, sourcemap: mode !== 'production', }, define: {