Refactor preload script

This commit is contained in:
Ottomated
2024-05-16 19:25:03 -07:00
parent 6e43cbb4d7
commit 3f8ead8a05
36 changed files with 962 additions and 1495 deletions

View File

@@ -0,0 +1,23 @@
import { settingsStore } from "../../scripts/settings";
import { $tidalState, coverArtPaths } from "../state";
import { settings } from "../../constants/settings";
import { Notification } from "@electron/remote";
let currentNotification: Electron.Notification | undefined;
$tidalState.subscribe(async (state, prevState) => {
if (!settingsStore.get(settings.notifications)) return;
if (!state.currentTrack) return;
if (state.currentTrack.id === prevState.currentTrack?.id) return;
currentNotification?.close();
if (state.status !== "Playing") return;
const icon = await coverArtPaths.get(state.currentTrack.image);
currentNotification = new Notification({
title: state.currentTrack.title,
body: state.currentTrack.artists.join(", "),
icon,
});
currentNotification.show();
});