diff --git a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx index b5e2dfd7a..0f2351c7f 100644 --- a/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx +++ b/app/assets/javascripts/components/AttachedFilesPopover/AttachedFilesPopover.tsx @@ -5,13 +5,7 @@ import { ContentType, SNFile, SNNote } from '@standardnotes/snjs'; import { FilesIllustration } from '@standardnotes/stylekit'; import { observer } from 'mobx-react-lite'; import { FunctionComponent } from 'preact'; -import { - StateUpdater, - useCallback, - useEffect, - useRef, - useState, -} from 'preact/hooks'; +import { StateUpdater, useEffect, useRef, useState } from 'preact/hooks'; import { Button } from '../Button'; import { Icon } from '../Icon'; import { PopoverFileItem } from './PopoverFileItem'; @@ -63,35 +57,30 @@ export const AttachedFilesPopover: FunctionComponent = observer( ) : filesList; - const reloadAttachedFiles = useCallback(() => { - setAttachedFiles( - application.items - .getFilesForNote(note) - .sort((a, b) => (a.created_at < b.created_at ? 1 : -1)) - ); - }, [application.items, note]); - - const reloadAllFiles = useCallback(() => { - setAllFiles( - application - .getItems(ContentType.File) - .sort((a, b) => (a.created_at < b.created_at ? 1 : -1)) as SNFile[] - ); - }, [application]); - useEffect(() => { const unregisterFileStream = application.streamItems( ContentType.File, () => { - reloadAttachedFiles(); - reloadAllFiles(); + setAttachedFiles( + application.items + .getFilesForNote(note) + .sort((a, b) => (a.created_at < b.created_at ? 1 : -1)) + ); + + setAllFiles( + application + .getItems(ContentType.File) + .sort((a, b) => + a.created_at < b.created_at ? 1 : -1 + ) as SNFile[] + ); } ); return () => { unregisterFileStream(); }; - }, [application, reloadAllFiles, reloadAttachedFiles]); + }, [application, note]); const handleAttachFilesClick = async () => { const uploadedFiles = await appState.files.uploadNewFile(); @@ -195,12 +184,7 @@ export const AttachedFilesPopover: FunctionComponent = observer( ) : (
- +
{searchQuery.length > 0