Skip to content

Commit

Permalink
remove unnecessary replicate state
Browse files Browse the repository at this point in the history
  • Loading branch information
LuKks committed Mar 30, 2023
1 parent 1bd798a commit 78d9a78
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const useSwarm = () => {

export const useReplicate = (core, deps = []) => {
const { swarm } = useSwarm()
const [replicate, setReplicate] = useState(false)

useEffect(() => {
if (!swarm || !core || core.closed) return
Expand All @@ -65,8 +64,6 @@ export const useReplicate = (core, deps = []) => {
session.on('connection', onsocket)
session.join(core.discoveryKey, { server: false, client: true })
session.flush().then(done, done)

setReplicate(true)
})

return () => {
Expand All @@ -75,11 +72,6 @@ export const useReplicate = (core, deps = []) => {
if (!session) return

session.destroy().catch(safetyCatch) // Run on background

// + should setReplicate(false, swarm destroy) first?
setReplicate(false)
}
}, [swarm, core, ...deps])

return { replicate }
}

0 comments on commit 78d9a78

Please sign in to comment.