web: improve item flash animation when revealing item in list

this also fixes a potential memory leak due to event listener not unsubscribing
This commit is contained in:
Abdullah Atta
2025-03-27 13:48:25 +05:00
parent f0fd20051e
commit 174bb9a935
2 changed files with 5 additions and 4 deletions

View File

@@ -206,7 +206,7 @@ textarea,
}
.flash {
animation: flash 0.5s;
animation: flash 1s;
}
@keyframes flash {

View File

@@ -112,7 +112,7 @@ function ListContainer(props: ListContainerProps) {
let flashStartTimeout: NodeJS.Timeout;
let flashEndTimeout: NodeJS.Timeout;
AppEventManager.subscribe(
const event = AppEventManager.subscribe(
AppEvents.revealItemInList,
async (id?: string) => {
if (!id || !listRef.current) return;
@@ -133,16 +133,17 @@ function ListContainer(props: ListContainerProps) {
noteItem.classList.add("flash");
flashEndTimeout = setTimeout(() => {
noteItem.classList.remove("flash");
}, 1000);
}, 2000);
}, 500);
}
);
return () => {
event.unsubscribe();
clearTimeout(flashStartTimeout);
clearTimeout(flashEndTimeout);
};
}, []);
}, [items]);
useEffect(() => {
return () => {