Skip to content
This repository has been archived by the owner on Nov 25, 2023. It is now read-only.

Commit

Permalink
readme update, remove broken close
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 committed Jun 27, 2021
1 parent f5375cc commit 2d1c501
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 28 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
![Banner](assets/logo.png)
---

# portal
A two-way p2p folder syncing tool build on top of the [Hypercore protocol](https://hypercore-protocol.org/).

## TODO:
- [ ] tests :((
- [ ] hooks → https://github.com/testing-library/react-hooks-testing-library
- [ ] components → https://github.com/vadimdemedes/ink-testing-library
- [ ] registry → regular ava
- [ ] packaging + redistribution
- [ ] update notifier: https://www.npmjs.com/package/update-notifier
- [ ] write readme
- [ ] demo video
## Installation
```shell
$ npm install --global portal-sync

# Start using portal
$ portal new

# or
$ portal join [sessionID]
```

## Features
read/write streams for files of arbitrary size
Expand Down
Binary file added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion commands/join.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const Client = ({dir, isForceOverwrite, sessionId, verbose, tree}: IClientProps)
<FileTree registry={registryRenderableArray} full={tree}/>
<Stats registry={registryRenderableArray} totalBytes={stats.totalBytes} bytesPerSecond={stats.bytesPerSecond}/>
</DisplayComponent>
<Hotkeys close={hyper.hyperObj?.close}/>
<Hotkeys/>
<Errors errors={errors}/>
</Box>
</AppContextProvider>
Expand Down
2 changes: 1 addition & 1 deletion commands/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Host = ({dir, includeGitFiles, verbose, tree}: IHostProps) => {
<FileTree registry={registryRenderableArray} full={tree}/>
<Stats registry={registryRenderableArray} totalBytes={stats.totalBytes} bytesPerSecond={stats.bytesPerSecond}/>
</DisplayComponent>
<Hotkeys close={hyper.hyperObj?.close}/>
<Hotkeys/>
<Errors errors={errors}/>
</Box>
</AppContextProvider>
Expand Down
4 changes: 3 additions & 1 deletion components/FileTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const TruncatedTreeFile = ({file}: {file: ITreeRepresentation}) => (
)

// File tree display component
const DISPLAY_NUM = 50
const FileTree = ({registry, full}: IFileTreeProps) => {
const emptyMessage = full ?
<Text color="yellow">No files found</Text> :
Expand All @@ -89,9 +90,10 @@ const FileTree = ({registry, full}: IFileTreeProps) => {
return (
<Box flexDirection="column" marginY={1}>
<Text bold>Files</Text>
{files.length > 0 ? files.map((file, i) => (
{files.length > 0 ? files.slice(0, 50).map((file, i) => (
full ? <FullTreeFile key={i} file={file}/> : <TruncatedTreeFile key={i} file={file}/>
)) : emptyMessage}
{files.length > 50 && <Text bold color="cyan">...and {files.length - DISPLAY_NUM} more collapsed</Text>}
{full && <Legend/>}
</Box>
)
Expand Down
8 changes: 2 additions & 6 deletions components/Hotkeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ import useHotkey from '../hooks/useHotkey'
import {useAppContext} from '../contexts/App'
import Loader from './Loader'

interface IHotkeysProps {
close: undefined | (() => Promise<void>);
}

// Hotkey component to listen for hotkeys to exit
const Hotkeys = ({close}: IHotkeysProps) => {
useHotkey(close)
const Hotkeys = () => {
useHotkey()
const {closed} = useAppContext()
return closed ?
<Loader status="Cleaning up..." color="yellow"/> :
Expand Down
2 changes: 1 addition & 1 deletion contexts/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const AppContextProvider = ({children, hyper}: IAppContextProviderProps)
<Text color="red">Error connecting to hypercore: </Text>
<Text>{hyper.error}</Text>
</Text>
<Hotkeys close={hyper.hyperObj?.close}/>
<Hotkeys/>
</>
)
}
Expand Down
1 change: 0 additions & 1 deletion hooks/useDebouncedState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const useDebouncedState = (registry: Registry) => {

useEffect(() => {
update()

const handler = setTimeout(() => {
update()
}, 1000 / TARGET_REFRESH_RATE)
Expand Down
9 changes: 2 additions & 7 deletions hooks/useHotkey.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import {promisify} from 'util'
import {useApp, useInput} from 'ink'
import {useAppContext} from '../contexts/App'

const useHotkey = (close: undefined | (() => void)) => {
const useHotkey = () => {
const {exit} = useApp()
const {setClosed} = useAppContext()
useInput((input, key) => {
if (input === 'q' || key.escape) {
setClosed()
exit()
if (close) {
promisify(close)().finally(() => process.exit())
} else {
process.exit()
}
process.exit()
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion hooks/useUpdateNotify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import pkg from '../package.json'

const useUpdateNotify = () => {
useEffect(() => {
updateNotifier({pkg}).notify()
updateNotifier({pkg}).notify({isGlobal: true})
}, [])
}

Expand Down

0 comments on commit 2d1c501

Please sign in to comment.