mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-12-14 14:25:36 +01:00
24 lines
809 B
TypeScript
24 lines
809 B
TypeScript
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();
|
|
});
|