mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
Revert "refactor: profile switch (#5197)"
This reverts commit c2dcd86722.
This commit is contained in:
@@ -14,20 +14,10 @@ let nextId = 0;
|
||||
let notices: NoticeItem[] = [];
|
||||
const listeners: Set<Listener> = new Set();
|
||||
|
||||
function flushListeners() {
|
||||
function notifyListeners() {
|
||||
listeners.forEach((listener) => listener([...notices])); // Pass a copy
|
||||
}
|
||||
|
||||
let notifyScheduled = false;
|
||||
function scheduleNotify() {
|
||||
if (notifyScheduled) return;
|
||||
notifyScheduled = true;
|
||||
requestAnimationFrame(() => {
|
||||
notifyScheduled = false;
|
||||
flushListeners();
|
||||
});
|
||||
}
|
||||
|
||||
// Shows a notification.
|
||||
|
||||
export function showNotice(
|
||||
@@ -54,7 +44,7 @@ export function showNotice(
|
||||
}
|
||||
|
||||
notices = [...notices, newNotice];
|
||||
scheduleNotify();
|
||||
notifyListeners();
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -66,7 +56,7 @@ export function hideNotice(id: number) {
|
||||
clearTimeout(notice.timerId); // Clear timeout if manually closed
|
||||
}
|
||||
notices = notices.filter((n) => n.id !== id);
|
||||
scheduleNotify();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Subscribes a listener function to notice state changes.
|
||||
@@ -87,5 +77,5 @@ export function clearAllNotices() {
|
||||
if (n.timerId) clearTimeout(n.timerId);
|
||||
});
|
||||
notices = [];
|
||||
scheduleNotify();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user