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:
@@ -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) {
|
||||
|
||||
15
lib/shared/notifications.ts
Normal file
15
lib/shared/notifications.ts
Normal 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;
|
||||
}
|
||||
3
lib/types/volume.d.ts
vendored
Normal file
3
lib/types/volume.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export type VolumeIcons = {
|
||||
[index: number]: string
|
||||
}
|
||||
Reference in New Issue
Block a user