From bdeb46a1944ea3f265aebf7e5d8f02bfc5e42004 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Tue, 5 Mar 2024 10:37:16 +0100 Subject: [PATCH] feat: :children_crossing: add event bus to player for auto update list --- src/store/player.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/store/player.js b/src/store/player.js index eb19fd6..edc357b 100644 --- a/src/store/player.js +++ b/src/store/player.js @@ -1,3 +1,4 @@ +import { EventBus } from './bus.js' import axios from '@nextcloud/axios' import { decodeUrl } from '../utils/url.js' import { formatEpisodeTimestamp } from '../utils/time.js' @@ -105,16 +106,21 @@ export const player = { context.dispatch('pause') context.commit('episode', null) }, - time: async (context) => axios.post(generateUrl('/apps/gpoddersync/episode_action/create'), [{ - podcast: context.state.podcastUrl, - episode: context.state.episode.url, - guid: context.state.episode.guid, - action: 'play', - timestamp: formatEpisodeTimestamp(new Date()), - started: Math.round(context.state.started), - position: Math.round(audio.currentTime), - total: Math.round(audio.duration), - }]), + time: async (context) => { + const episode = context.state.episode + episode.action = { + podcast: context.state.podcastUrl, + episode: context.state.episode.url, + guid: context.state.episode.guid, + action: 'play', + timestamp: formatEpisodeTimestamp(new Date()), + started: Math.round(context.state.started), + position: Math.round(audio.currentTime), + total: Math.round(audio.duration), + } + axios.post(generateUrl('/apps/gpoddersync/episode_action/create'), [episode.action]) + EventBus.$emit('updateEpisodesList', episode) + }, volume: (_, volume) => { audio.volume = volume },