mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-16 03:52:17 +08:00
fix: address notification review feedback
This commit is contained in:
@@ -33,12 +33,17 @@ const clearTitleIndicator = (): void => {
|
||||
}
|
||||
|
||||
removeReturnListeners();
|
||||
removePageInactiveListener();
|
||||
|
||||
if (document.title.startsWith(getIndicatorPrefix())) {
|
||||
document.title = stripIndicator(document.title);
|
||||
}
|
||||
};
|
||||
|
||||
const removePageInactiveListener = (): void => {
|
||||
document.removeEventListener('visibilitychange', handlePageInactive);
|
||||
};
|
||||
|
||||
const scheduleClear = (): void => {
|
||||
if (clearTimer !== null) {
|
||||
window.clearTimeout(clearTimer);
|
||||
@@ -47,6 +52,9 @@ const scheduleClear = (): void => {
|
||||
clearTimer = window.setTimeout(() => {
|
||||
clearTitleIndicator();
|
||||
}, TITLE_INDICATOR_CLEAR_DELAY_MS);
|
||||
|
||||
removePageInactiveListener();
|
||||
document.addEventListener('visibilitychange', handlePageInactive, { once: true });
|
||||
};
|
||||
|
||||
function handleUserReturn(): void {
|
||||
@@ -59,6 +67,24 @@ function handleUserReturn(): void {
|
||||
scheduleClear();
|
||||
}
|
||||
|
||||
function handlePageInactive(): void {
|
||||
if (document.visibilityState !== 'hidden') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (clearTimer !== null) {
|
||||
window.clearTimeout(clearTimer);
|
||||
clearTimer = null;
|
||||
}
|
||||
|
||||
if (!returnListenersAttached) {
|
||||
document.addEventListener('visibilitychange', handleUserReturn);
|
||||
window.addEventListener('focus', handleUserReturn, true);
|
||||
window.addEventListener('click', handleUserReturn, true);
|
||||
returnListenersAttached = true;
|
||||
}
|
||||
}
|
||||
|
||||
export const showCompletionTitleIndicator = (): void => {
|
||||
if (typeof document === 'undefined' || typeof window === 'undefined') {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user