Show reload notification on config update
This commit is contained in:
1 parent
6c60ce6457
commit
83dba52e96
7 files changed
+122
-37
No files matched your search
+20
-6
@@ -4,18 +4,32 @@ interface Notification {
|
||||
type: string;
|
||||
message: string;
|
||||
timestamp: number;
|
||||
actions?: { [label: string]: () => void };
|
||||
}
|
||||
|
||||
const notifications = new Set<Notification>();
|
||||
|
||||
export function push(type, message): void {
|
||||
const n = { type: type, message: message, timestamp: Date.now() };
|
||||
export function push(type, message, actions?): Notification {
|
||||
const n: Notification = {
|
||||
type: type,
|
||||
message: message,
|
||||
timestamp: Date.now(),
|
||||
actions: actions
|
||||
};
|
||||
notifications.add(n);
|
||||
m.redraw();
|
||||
setTimeout(() => {
|
||||
notifications.delete(n);
|
||||
m.redraw();
|
||||
}, 4000);
|
||||
if (!actions) {
|
||||
setTimeout(() => {
|
||||
dismiss(n);
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
export function dismiss(n: Notification): void {
|
||||
notifications.delete(n);
|
||||
m.redraw();
|
||||
}
|
||||
|
||||
export function getNotifications(): Set<Notification> {
|
||||
|
||||
Reference in new issue
Block a user