File tree Expand file tree Collapse file tree 3 files changed +6
-13
lines changed
Expand file tree Collapse file tree 3 files changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -30,10 +30,6 @@ export default () => {
3030 const setSelectedFiles = ServerContext . useStoreActions ( actions => actions . files . setSelectedFiles ) ;
3131
3232 useEffect ( ( ) => {
33- // We won't automatically mutate the store when the component re-mounts, otherwise because of
34- // my (horrible) programming this fires off way more than we intend it to.
35- mutate ( ) ;
36-
3733 setSelectedFiles ( [ ] ) ;
3834 setDirectory ( hash . length > 0 ? hash : '/' ) ;
3935 } , [ hash ] ) ;
Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ const Row = styled.div`
1818
1919const FileObjectRow = ( { file } : { file : FileObject } ) => {
2020 const directory = ServerContext . useStoreState ( state => state . files . directory ) ;
21- const setDirectory = ServerContext . useStoreActions ( actions => actions . files . setDirectory ) ;
2221
2322 const history = useHistory ( ) ;
2423 const match = useRouteMatch ( ) ;
@@ -31,9 +30,7 @@ const FileObjectRow = ({ file }: { file: FileObject }) => {
3130 // Just trust me future me, leave this be.
3231 if ( ! file . isFile ) {
3332 e . preventDefault ( ) ;
34-
3533 history . push ( `#${ cleanDirectoryPath ( `${ directory } /${ file . name } ` ) } ` ) ;
36- setDirectory ( `${ directory } /${ file . name } ` ) ;
3734 }
3835 } ;
3936
Original file line number Diff line number Diff line change @@ -2,18 +2,18 @@ import useSWR from 'swr';
22import loadDirectory , { FileObject } from '@/api/server/files/loadDirectory' ;
33import { cleanDirectoryPath } from '@/helpers' ;
44import useServer from '@/plugins/useServer' ;
5- import { useLocation } from 'react-router ' ;
5+ import { ServerContext } from '@/state/server ' ;
66
77export default ( ) => {
88 const { uuid } = useServer ( ) ;
9- const { hash } = useLocation ( ) ;
9+ const directory = ServerContext . useStoreState ( state => state . files . directory ) ;
1010
1111 return useSWR < FileObject [ ] > (
12- `${ uuid } :files:${ hash } ` ,
13- ( ) => loadDirectory ( uuid , cleanDirectoryPath ( hash ) ) ,
12+ `${ uuid } :files:${ directory } ` ,
13+ ( ) => loadDirectory ( uuid , cleanDirectoryPath ( directory ) ) ,
1414 {
15- revalidateOnMount : false ,
15+ revalidateOnMount : true ,
1616 refreshInterval : 0 ,
17- }
17+ } ,
1818 ) ;
1919} ;
You can’t perform that action at this time.
0 commit comments