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 useTheme: (filePath: string) => void;
|
||||||
var getSystrayItems: () => string;
|
var getSystrayItems: () => string;
|
||||||
var isWindowVisible: (windowName: string) => boolean;
|
var isWindowVisible: (windowName: string) => boolean;
|
||||||
|
var clearAllNotifications: () => Promise<void>;
|
||||||
|
|
||||||
var globalWeatherVar: VariableType<Weather>;
|
var globalWeatherVar: VariableType<Weather>;
|
||||||
var options: Options;
|
var options: Options;
|
||||||
var removingNotifications: VariableType<boolean>;
|
var removingNotifications: VariableType<boolean>;
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
|
const notifs = await Service.import('notifications');
|
||||||
import icons from 'modules/icons/index';
|
import icons from 'modules/icons/index';
|
||||||
|
import options from 'options';
|
||||||
import { Notification } from 'types/service/notifications';
|
import { Notification } from 'types/service/notifications';
|
||||||
|
|
||||||
|
const { clearDelay } = options.notifications;
|
||||||
|
|
||||||
export const removingNotifications = Variable<boolean>(false);
|
export const removingNotifications = Variable<boolean>(false);
|
||||||
|
|
||||||
export const getNotificationIcon = (app_name: string, app_icon: string, app_entry: string): string => {
|
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;
|
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;
|
removingNotifications.value = true;
|
||||||
for (const notif of notifications) {
|
for (const notif of notifications) {
|
||||||
notif.close();
|
notif.close();
|
||||||
@@ -34,4 +38,9 @@ export const closeNotifications = async (notifications: Notification[], delay: n
|
|||||||
removingNotifications.value = false;
|
removingNotifications.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const clearAllNotifications = async (): Promise<void> => {
|
||||||
|
clearNotifications(notifs.notifications, clearDelay.value);
|
||||||
|
};
|
||||||
|
|
||||||
globalThis['removingNotifications'] = removingNotifications;
|
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 { BoxWidget } from 'lib/types/widget';
|
||||||
import { Notifications } from 'types/service/notifications';
|
import { Notifications } from 'types/service/notifications';
|
||||||
import options from 'options';
|
import options from 'options';
|
||||||
@@ -53,7 +53,7 @@ const Controls = (notifs: Notifications): BoxWidget => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return closeNotifications(notifs.notifications, delay);
|
return clearNotifications(notifs.notifications, delay);
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
child: Widget.Label({
|
child: Widget.Label({
|
||||||
|
|||||||
Reference in New Issue
Block a user