Revert "refactor: profile switch (#5197)"

This reverts commit c2dcd86722.
This commit is contained in:
Tunglies
2025-10-30 18:11:04 +08:00
parent 928f226d10
commit a869dbb441
36 changed files with 1257 additions and 5894 deletions

View File

@@ -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();
}