From 14ee13b28131236be2e2f473faf1998a459f5405 Mon Sep 17 00:00:00 2001 From: amsyarasyiq <82711525+amsyarasyiq@users.noreply.github.com> Date: Thu, 16 Mar 2023 21:47:54 +0800 Subject: [PATCH] feat(Last.fm): Hide when Spotify is running --- plugins/Last.fm/src/Settings.tsx | 8 ++++++++ plugins/Last.fm/src/constants.ts | 2 +- plugins/Last.fm/src/index.ts | 1 + plugins/Last.fm/src/types.ts | 9 +++++++++ plugins/Last.fm/src/utils.ts | 13 ++++++++++++- 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/plugins/Last.fm/src/Settings.tsx b/plugins/Last.fm/src/Settings.tsx index 9845a13..c4f17e5 100644 --- a/plugins/Last.fm/src/Settings.tsx +++ b/plugins/Last.fm/src/Settings.tsx @@ -86,6 +86,14 @@ export default function Settings() { onValueChange={(value: boolean) => settings.listeningTo = value} /> + } + value={settings.ignoreSpotify} + onValueChange={(value: boolean) => settings.ignoreSpotify = value} + /> + { @@ -98,6 +99,16 @@ async function update() { throw new Error("Username is not set"); } + if (currentSettings.ignoreSpotify) { + for (const activity of PresenceStore.getActivities()) { + if (activity?.type === ActivityType.LISTENING && activity.application_id !== Constants.APPLICATION_ID) { + verboseLog("--> Spotify is currently playing, aborting..."); + clearActivity(); + return; + } + } + } + const lastTrack = await fetchLatestScrobble().catch(async (err) => { verboseLog("--> An error occurred while fetching the last track, aborting..."); clearActivity();