Auto-refresh notes and sidebar when returning to Everclone tab
This commit is contained in:
1 parent
781b64ee3b
commit
25560b0e82
1 file changed
+18
@@ -634,6 +634,24 @@ export default function EvercloneWorkspace() {
|
|||||||
fetchNotesList();
|
fetchNotesList();
|
||||||
}, [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
|
// Fetch full note details when selectedNoteId changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!selectedNoteId) {
|
if (!selectedNoteId) {
|
||||||
|
|||||||
Reference in new issue
Block a user