Provide a cli command to clear notifications. (#444)

This commit is contained in:
Jas Singh
2024-11-05 21:11:50 -08:00
committed by GitHub
parent 6250c2b3be
commit ec3be1cad8
3 changed files with 14 additions and 3 deletions

View File

@@ -1,6 +1,10 @@
const notifs = await Service.import('notifications');
import icons from 'modules/icons/index';
import options from 'options';
import { Notification } from 'types/service/notifications';
const { clearDelay } = options.notifications;
export const removingNotifications = Variable<boolean>(false);
export const getNotificationIcon = (app_name: string, app_icon: string, app_entry: string): string => {
@@ -25,7 +29,7 @@ export const getNotificationIcon = (app_name: string, app_icon: string, app_entr
return icon;
};
export const closeNotifications = async (notifications: Notification[], delay: number): Promise<void> => {
export const clearNotifications = async (notifications: Notification[], delay: number): Promise<void> => {
removingNotifications.value = true;
for (const notif of notifications) {
notif.close();
@@ -34,4 +38,9 @@ export const closeNotifications = async (notifications: Notification[], delay: n
removingNotifications.value = false;
};
const clearAllNotifications = async (): Promise<void> => {
clearNotifications(notifs.notifications, clearDelay.value);
};
globalThis['removingNotifications'] = removingNotifications;
globalThis['clearAllNotifications'] = clearAllNotifications;