From 42035d6e181b321074029ca68cf54342a8d39827 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Tue, 27 Aug 2024 16:11:12 +0200 Subject: [PATCH] refactor: :boom: big rewrite to extract episode to his own component --- src/components/Atoms/Modal.vue | 50 ++--- src/components/Feed/Episode.vue | 203 +++++++++++++++++ src/components/Feed/Episodes.vue | 205 +----------------- src/components/Feed/Favorites.vue | 97 +++++++++ src/components/Home/Episode.vue | 0 src/components/Home/Favorites.vue | 39 ---- src/components/Player/Infos.vue | 9 +- .../Sidebar/{Item.vue => Subscription.vue} | 2 +- src/components/Sidebar/Subscriptions.vue | 11 +- src/store/player.js | 3 +- src/utils/status.js | 14 ++ src/views/Home.vue | 2 +- 12 files changed, 349 insertions(+), 286 deletions(-) create mode 100644 src/components/Feed/Episode.vue create mode 100644 src/components/Feed/Favorites.vue delete mode 100644 src/components/Home/Episode.vue delete mode 100644 src/components/Home/Favorites.vue rename src/components/Sidebar/{Item.vue => Subscription.vue} (99%) create mode 100644 src/utils/status.js diff --git a/src/components/Atoms/Modal.vue b/src/components/Atoms/Modal.vue index 1026183..669378a 100644 --- a/src/components/Atoms/Modal.vue +++ b/src/components/Atoms/Modal.vue @@ -1,25 +1,29 @@ - - diff --git a/src/components/Feed/Favorites.vue b/src/components/Feed/Favorites.vue new file mode 100644 index 0000000..16f7605 --- /dev/null +++ b/src/components/Feed/Favorites.vue @@ -0,0 +1,97 @@ + + + + + diff --git a/src/components/Home/Episode.vue b/src/components/Home/Episode.vue deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/Home/Favorites.vue b/src/components/Home/Favorites.vue deleted file mode 100644 index e250955..0000000 --- a/src/components/Home/Favorites.vue +++ /dev/null @@ -1,39 +0,0 @@ - - - diff --git a/src/components/Player/Infos.vue b/src/components/Player/Infos.vue index 7240386..5ad45a9 100644 --- a/src/components/Player/Infos.vue +++ b/src/components/Player/Infos.vue @@ -7,14 +7,7 @@ {{ episode.title }} - + diff --git a/src/components/Sidebar/Item.vue b/src/components/Sidebar/Subscription.vue similarity index 99% rename from src/components/Sidebar/Item.vue rename to src/components/Sidebar/Subscription.vue index bd05cb0..e52d015 100644 --- a/src/components/Sidebar/Item.vue +++ b/src/components/Sidebar/Subscription.vue @@ -52,7 +52,7 @@ import { toFeedUrl } from '../../utils/url.js' import { useSubscriptions } from '../../store/subscriptions.js' export default { - name: 'Item', + name: 'Subscription', components: { AlertIcon, DeleteIcon, diff --git a/src/components/Sidebar/Subscriptions.vue b/src/components/Sidebar/Subscriptions.vue index 747b708..e77520e 100644 --- a/src/components/Sidebar/Subscriptions.vue +++ b/src/components/Sidebar/Subscriptions.vue @@ -11,13 +11,14 @@ - fav.url) + .filter((url) => subs.includes(url))" :key="url" :url="url" /> - ({ loading: true, diff --git a/src/store/player.js b/src/store/player.js index adb4b41..25c9830 100644 --- a/src/store/player.js +++ b/src/store/player.js @@ -48,8 +48,7 @@ export const usePlayer = defineStore('player', { } catch {} if ( - this.episode.action && - this.episode.action.position && + this.episode.action?.position && this.episode.action.position < this.episode.action.total ) { audio.currentTime = this.episode.action.position diff --git a/src/utils/status.js b/src/utils/status.js new file mode 100644 index 0000000..44774bb --- /dev/null +++ b/src/utils/status.js @@ -0,0 +1,14 @@ +export const hasEnded = (episode) => + episode.action && + episode.action.action && + (episode.action.action.toLowerCase() === 'delete' || + (episode.action.position > 0 && + episode.action.total > 0 && + episode.action.position >= episode.action.total)) + +export const isListening = (episode) => + episode.action && + episode.action.action && + episode.action.action.toLowerCase() === 'play' && + episode.action.position > 0 && + !hasEnded(episode) diff --git a/src/views/Home.vue b/src/views/Home.vue index 6965998..110be94 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -24,7 +24,7 @@