Auto-refresh notes and sidebar when returning to Everclone tab

This commit is contained in:
chrisf committed 2026-10-23 11:28:44 -06:00
1 parent 781b64ee3b
commit 25560b0e82
1 file changed
+18
+18
View File
@@ -634,6 +634,24 @@ export default function EvercloneWorkspace() {
fetchNotesList();
}, [fetchNotesList]);
// Window Focus & Visibility Listener:
// When switching back to the Everclone tab after clipping something with the browser extension or another app,
// automatically re-check notes so new clips instantly appear at the top without requiring a manual search/refresh.
useEffect(() => {
const handleSyncOnFocus = () => {
if (document.visibilityState === 'visible') {
fetchSidebar();
fetchNotesList();
}
};
window.addEventListener('focus', handleSyncOnFocus);
document.addEventListener('visibilitychange', handleSyncOnFocus);
return () => {
window.removeEventListener('focus', handleSyncOnFocus);
document.removeEventListener('visibilitychange', handleSyncOnFocus);
};
}, [fetchNotesList, fetchSidebar]);
// Fetch full note details when selectedNoteId changes
useEffect(() => {
if (!selectedNoteId) {