mirror of
https://github.com/streamwall/streamwall.git
synced 2026-01-24 22:22:50 -05:00
Prevent control page echoing back CRDT updates
This commit is contained in:
@@ -144,14 +144,17 @@ function useStreamwallConnection(wsEndpoint) {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
function sendUpdate(update) {
|
||||
function sendUpdate(update, origin) {
|
||||
if (origin === 'server') {
|
||||
return
|
||||
}
|
||||
wsRef.current.send(update)
|
||||
}
|
||||
function receiveUpdate(ev) {
|
||||
if (!(ev.data instanceof ArrayBuffer)) {
|
||||
return
|
||||
}
|
||||
Y.applyUpdate(stateDoc, new Uint8Array(ev.data))
|
||||
Y.applyUpdate(stateDoc, new Uint8Array(ev.data), 'server')
|
||||
}
|
||||
stateDoc.on('update', sendUpdate)
|
||||
wsRef.current.addEventListener('message', receiveUpdate)
|
||||
|
||||
Reference in New Issue
Block a user