Skip to content

Commit

Permalink
Add strict mode
Browse files Browse the repository at this point in the history
And fixes duplicate key bug due to socket automatic reconnection
  • Loading branch information
reyronald committed Apr 6, 2024
1 parent 7759ae3 commit 7bbc69d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/ACTListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ type Callback = (
type EventData = {
type: "broadcast"
msgtype: "Chat" | "SendCharName"
msg: string
}
msg: string
}

export default function listenToACT(callback: Callback) {
if (!getHost()) return listenOverlayPlugin(callback)
Expand All @@ -24,10 +24,6 @@ function listenActWebSocket(callback: Callback) {

const ws = new WebSocket(wsUri)
ws.onerror = () => ws.close()
ws.onclose = () =>
setTimeout(() => {
listenActWebSocket(callback)
}, 1000)
ws.onmessage = function (e) {
if (e.data === ".") return ws.send(".")

Expand Down
7 changes: 6 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import ReactDOM from "react-dom/client"

import App from "./App"
import { StrictMode } from "react"

const container = document.getElementById("root")

if (!container) throw new Error("Missing #root element")

const root = ReactDOM.createRoot(container)

root.render(<App />)
root.render(
<StrictMode>
<App />
</StrictMode>,
)

0 comments on commit 7bbc69d

Please sign in to comment.