Provide a cli command to clear notifications. (#444)
This commit is contained in:
2
globals.d.ts
vendored
2
globals.d.ts
vendored
@@ -7,6 +7,8 @@ declare global {
|
||||
var useTheme: (filePath: string) => void;
|
||||
var getSystrayItems: () => string;
|
||||
var isWindowVisible: (windowName: string) => boolean;
|
||||
var clearAllNotifications: () => Promise<void>;
|
||||
|
||||
var globalWeatherVar: VariableType<Weather>;
|
||||
var options: Options;
|
||||
var removingNotifications: VariableType<boolean>;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { closeNotifications } from 'globals/notification';
|
||||
import { clearNotifications } from 'globals/notification';
|
||||
import { BoxWidget } from 'lib/types/widget';
|
||||
import { Notifications } from 'types/service/notifications';
|
||||
import options from 'options';
|
||||
@@ -53,7 +53,7 @@ const Controls = (notifs: Notifications): BoxWidget => {
|
||||
return;
|
||||
}
|
||||
|
||||
return closeNotifications(notifs.notifications, delay);
|
||||
return clearNotifications(notifs.notifications, delay);
|
||||
};
|
||||
}),
|
||||
child: Widget.Label({
|
||||
|
||||
Reference in New Issue
Block a user