File tree Expand file tree Collapse file tree 2 files changed +6
-9
lines changed
src/script/components/InputBar/useFileHandling/useFilePaste Expand file tree Collapse file tree 2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ describe('useFilePaste', () => {
6767 const calledWithFile = mockOnFilePasted . mock . calls [ 0 ] [ 0 ] ;
6868 expect ( calledWithFile instanceof File ) . toBe ( true ) ;
6969 expect ( calledWithFile . name ) . toBe ( `Pasted file from ${ mockFormattedDate } .txt` ) ;
70+ expect ( checkFileSharingPermissionModule . checkFileSharingPermission ) . toHaveBeenCalled ( ) ;
7071 } ) ;
7172
7273 it ( 'ignores paste events with text/plain content' , ( ) => {
@@ -79,6 +80,7 @@ describe('useFilePaste', () => {
7980 } ) ;
8081
8182 expect ( mockOnFilePasted ) . not . toHaveBeenCalled ( ) ;
83+ expect ( checkFileSharingPermissionModule . checkFileSharingPermission ) . not . toHaveBeenCalled ( ) ;
8284 } ) ;
8385
8486 it ( 'does nothing when no files are pasted' , ( ) => {
@@ -92,12 +94,6 @@ describe('useFilePaste', () => {
9294
9395 expect ( mockOnFilePasted ) . not . toHaveBeenCalled ( ) ;
9496 } ) ;
95-
96- it ( 'uses checkFileSharingPermission wrapper' , ( ) => {
97- renderHook ( ( ) => useFilePaste ( { onFilePasted : mockOnFilePasted } ) ) ;
98-
99- expect ( checkFileSharingPermissionModule . checkFileSharingPermission ) . toHaveBeenCalled ( ) ;
100- } ) ;
10197} ) ;
10298
10399/**
Original file line number Diff line number Diff line change @@ -60,14 +60,15 @@ export const useFilePaste = ({onFilePasted}: UseFilePasteParams) => {
6060 const files = event . clipboardData ?. files ;
6161
6262 if ( files ) {
63- processClipboardFiles ( files ) ;
63+ const permissionHandler = checkFileSharingPermission ( processClipboardFiles ) ;
64+ permissionHandler ( files ) ;
6465 }
6566 } ,
6667 [ processClipboardFiles ] ,
6768 ) ;
6869
6970 useEffect ( ( ) => {
70- document . addEventListener ( 'paste' , checkFileSharingPermission ( handlePasteEvent ) ) ;
71- return ( ) => document . removeEventListener ( 'paste' , checkFileSharingPermission ( handlePasteEvent ) ) ;
71+ document . addEventListener ( 'paste' , handlePasteEvent ) ;
72+ return ( ) => document . removeEventListener ( 'paste' , handlePasteEvent ) ;
7273 } , [ handlePasteEvent ] ) ;
7374} ;
You can’t perform that action at this time.
0 commit comments