Added filters for notifications and system tray items. (#234)

* Added filters for notifications and systray. closes #233

* Add links to documentation.
This commit is contained in:
Jas Singh
2024-09-08 02:01:13 -07:00
committed by GitHub
parent bd573ec4e7
commit 4f91bb8b8f
22 changed files with 630 additions and 174 deletions

View File

@@ -13,17 +13,17 @@ export const getCurrentPlayer = (activePlayer: MprisPlayer = mpris.players[0]):
}
const isPlaying = mpris.players.some(
(p) => p["play-back-status"] === "Playing",
(p: MprisPlayer) => p.play_back_status === "Playing",
);
const playerStillExists = mpris.players.some(
(p) => activePlayer["bus-name"] === p["bus-name"],
(p) => activePlayer.bus_name === p.bus_name
);
const nextPlayerUp = mpris.players.sort(
(a, b) =>
statusOrder[a["play-back-status"]] -
statusOrder[b["play-back-status"]],
(a: MprisPlayer, b: MprisPlayer) =>
statusOrder[a.play_back_status] -
statusOrder[b.play_back_status],
)[0];
if (isPlaying || !playerStillExists) {

View File

@@ -0,0 +1,15 @@
import { Notification } from "types/service/notifications";
export const filterNotifications = (notifications: Notification[], filter: string[]): Notification[] => {
const notifFilter = new Set(
filter.map((name: string) => name.toLowerCase().replace(/\s+/g, '_'))
);
const filteredNotifications = notifications.filter((notif: Notification) => {
const normalizedAppName = notif.app_name.toLowerCase().replace(/\s+/g, '_');
return !notifFilter.has(normalizedAppName);
});
return filteredNotifications;
}