From da2a831d3771e8ea34eb9a9b71e2f5fac1fd59b1 Mon Sep 17 00:00:00 2001 From: geoffrey45 Date: Mon, 27 Dec 2021 16:38:19 +0300 Subject: [PATCH] minor refactors --- src/composables/mediaNotification.js | 18 ++++++++++-------- src/composables/perks.js | 5 ++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/composables/mediaNotification.js b/src/composables/mediaNotification.js index 8065639c..f9a7a6ff 100644 --- a/src/composables/mediaNotification.js +++ b/src/composables/mediaNotification.js @@ -2,38 +2,40 @@ import perks from "./perks.js"; import playAudio from "./playAudio.js"; let showMediaNotif = () => { + let current = perks.current.value; + if ("mediaSession" in navigator) { navigator.mediaSession.metadata = new window.MediaMetadata({ - title: perks.current.value.title, - artist: perks.current.value.artists, + title: current.title, + artist: current.artists, artwork: [ { - src: perks.current.value.image, + src: current.image, sizes: "96x96", type: "image/jpeg", }, { - src: perks.current.value.image, + src: current.image, sizes: "128x128", type: "image/png", }, { - src: perks.current.value.image, + src: current.image, sizes: "192x192", type: "image/png", }, { - src: perks.current.value.image, + src: current.image, sizes: "256x256", type: "image/png", }, { - src: perks.current.value.image, + src: current.image, sizes: "384x384", type: "image/png", }, { - src: perks.current.value.image, + src: current.image, sizes: "512x512", type: "image/png", }, diff --git a/src/composables/perks.js b/src/composables/perks.js index a60d24bd..5a9f4c6c 100644 --- a/src/composables/perks.js +++ b/src/composables/perks.js @@ -1,7 +1,7 @@ import { ref } from "@vue/reactivity"; import { watch } from "@vue/runtime-core"; -import media from './mediaNotification.js' +import media from "./mediaNotification.js"; const current = ref({ title: "Nothing played yet", @@ -82,7 +82,7 @@ const readQueue = () => { }; watch(current, (new_current, old_current) => { - media.showMediaNotif() + media.showMediaNotif(); localStorage.setItem("current", JSON.stringify(new_current)); const index = queue.value.findIndex( @@ -113,5 +113,4 @@ watch(current, (new_current, old_current) => { }, 1000); }); - export default { putCommas, doThat, readQueue, current, queue, next, prev };