-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
735 additions
and
763 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {useState, useEffect} from 'react'; | ||
import {useLocation} from 'react-exo/navigation'; | ||
|
||
export function useCurrentResource() { | ||
const {pathname, hash} = useLocation(); | ||
const [path, setPath] = useState(hash ? `${pathname}/${hash?.slice(1)}` : ''); | ||
const [maximized, setMaximized] = useState(true); | ||
|
||
useEffect(() => { | ||
if (hash) { | ||
const _path = `${pathname}/${hash?.slice(1)}`; | ||
if (_path !== path) { | ||
setPath(_path); | ||
} | ||
setMaximized(true); | ||
} else { | ||
setMaximized(false); | ||
} | ||
}, [pathname, hash, path]); | ||
|
||
return {path, maximized, setPath, setMaximized}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,25 @@ | ||
import {useCallback} from 'react'; | ||
import {fs} from 'react-exo/fs'; | ||
|
||
import type {OpenDirectoryOptions} from 'react-exo/fs'; | ||
import {useCallback} from 'react'; | ||
import {getStartInDir} from 'media/utils/path'; | ||
|
||
export function useFileSystem() { | ||
const getOpenDirectoryInit = useCallback((path: string) => { | ||
let startIn: OpenDirectoryOptions['startIn']; | ||
switch (path) { | ||
case 'documents': startIn = 'documents'; break; | ||
case 'pictures': startIn = 'pictures'; break; | ||
case 'videos': startIn = 'videos'; break; | ||
case 'music': startIn = 'music'; break; | ||
case 'downloads': startIn = 'downloads'; break; | ||
default: startIn = 'desktop'; | ||
} | ||
return startIn; | ||
}, []); | ||
|
||
const importDirectory = useCallback(async (path = '.') => { | ||
const startIn = getOpenDirectoryInit(path); | ||
const dir = await fs.openDirectory({id: path, startIn, mode: 'read'}); | ||
const start = performance.now(); | ||
const copy = await fs.importDirectory(dir, path); | ||
console.log('[fs] import dir', copy, performance.now() - start); | ||
}, [getOpenDirectoryInit]); | ||
|
||
const importFile = useCallback(async () => { | ||
const perfStart = performance.now(); | ||
const file = await fs.openFile(); | ||
console.log('[fs] file', file); | ||
const start = performance.now(); | ||
const copy = await fs.importFile(file); | ||
console.log('[fs] import file', copy, performance.now() - start); | ||
console.log('[fs] import file', file, copy, performance.now() - perfStart); | ||
}, []); | ||
|
||
const hashFile = useCallback(async () => { | ||
const file = await fs.openFile(); | ||
console.log('[fs] file', file); | ||
const start = performance.now(); | ||
const hash = await fs.hashFile(file, (bytes, total) => { | ||
console.log('[fs] hashing', (bytes / total) * 100); | ||
}); | ||
console.log('[fs] hash', hash, performance.now() - start); | ||
const importDirectory = useCallback(async (path = '.') => { | ||
const perfStart = performance.now(); | ||
const startIn = getStartInDir(path); | ||
const dir = await fs.openDirectory({id: path, startIn, mode: 'read'}); | ||
const copy = await fs.importDirectory(dir, path); | ||
console.log('[fs] import dir', dir, copy, performance.now() - perfStart); | ||
}, []); | ||
|
||
return { | ||
getOpenDirectoryInit, | ||
importDirectory, | ||
importFile, | ||
hashFile, | ||
importDirectory, | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.