Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
- update dependencies
- ignore `.partykit` folder
- use `usePartySocket`
- pass lint
- add `.prettierrc`
  • Loading branch information
threepointone committed Jan 1, 2024
1 parent 6927699 commit 200ecde
Show file tree
Hide file tree
Showing 7 changed files with 740 additions and 679 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ dist-ssr
*.sw?
.vercel

.env
.env
.partykit
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"useTabs": true,
"singleQuote": true,
"semi": false
}
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
},
"dependencies": {
"@tldraw/tldraw": "^2.0.0-canary.f7ae99dd1fc9",
"partykit": "^0.0.27",
"partysocket": "^0.0.17",
"partykit": "^0.0.59",
"partysocket": "^0.0.18",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react": "^4.0.3",
"concurrently": "^8.2.0",
"eslint": "^8.45.0",
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"@vitejs/plugin-react": "^4.2.1",
"concurrently": "^8.2.2",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"typescript": "^5.0.2",
"vite": "^4.4.5"
"eslint-plugin-react-refresh": "^0.4.5",
"typescript": "^5.3.3",
"vite": "^5.0.10"
}
}
14 changes: 7 additions & 7 deletions src/useSyncStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
uniqueId,
} from '@tldraw/tldraw'
import { useEffect, useState } from 'react'
import PartySocket from 'partysocket'
import { usePartySocket } from 'partysocket/react'

const clientId = uniqueId()

Expand All @@ -34,12 +34,12 @@ export function useSyncStore({
status: 'loading',
})

useEffect(() => {
const socket = new PartySocket({
host: hostUrl,
room: `${roomId}_${version}`,
})
const socket = usePartySocket({
host: hostUrl,
room: `${roomId}_${version}`,
})

useEffect(() => {
setStoreWithStatus({ status: 'loading' })

const unsubs: (() => void)[] = []
Expand Down Expand Up @@ -161,7 +161,7 @@ export function useSyncStore({
unsubs.length = 0
socket.close()
}
}, [store])
}, [socket, store])

return storeWithStatus
}
Loading

0 comments on commit 200ecde

Please sign in to comment.