fix(sync): eliminate zombie focus, flush debounced state on window blur, remove stale closures and buffer ws messages
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 57s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 57s
This commit is contained in:
1 parent
06f5f7043c
commit
cedf5aebff
4 files changed
+221
-59
No files matched your search
@@ -320,8 +320,10 @@ func (r *DocRoom) HandleEvent(evt DocSyncEvent, sender *DocWSClient) {
|
||||
targetID = evt.Block.ID
|
||||
}
|
||||
if targetID != "" {
|
||||
found := false
|
||||
for i := range r.blocks {
|
||||
if r.blocks[i].ID == targetID {
|
||||
found = true
|
||||
if evt.Block != nil {
|
||||
r.blocks[i].Content = evt.Block.Content
|
||||
r.blocks[i].Level = evt.Block.Level
|
||||
@@ -359,6 +361,22 @@ func (r *DocRoom) HandleEvent(evt DocSyncEvent, sender *DocWSClient) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found && evt.Block != nil {
|
||||
newBlock := *evt.Block
|
||||
newBlock.DocumentID = r.docID
|
||||
if newBlock.Type == "" {
|
||||
newBlock.Type = "text"
|
||||
}
|
||||
if newBlock.Level < 0 {
|
||||
newBlock.Level = 0
|
||||
}
|
||||
r.blocks = append(r.blocks, newBlock)
|
||||
r.blocks = normalizeRoomBlocks(r.docID, r.blocks)
|
||||
bCopy := newBlock
|
||||
evt.Block = &bCopy
|
||||
evt.BlockID = targetID
|
||||
mutated = true
|
||||
}
|
||||
}
|
||||
|
||||
case "block_deleted":
|
||||
@@ -441,6 +459,11 @@ func (r *DocRoom) HandleEvent(evt DocSyncEvent, sender *DocWSClient) {
|
||||
select {
|
||||
case client.send <- msgBytes:
|
||||
default:
|
||||
slog.Warn("Doc room WS client send buffer full, dropping message",
|
||||
"doc_id", r.docID,
|
||||
"client_id", client.clientID,
|
||||
"user_id", client.userID,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user