Comments (5)
I looked into this a bit deeper today, and have found a sequence of operations that may cause history loss. Maybe this is what's happening for you here? It could happen if multiple calls to .pause()
would get made before .resume()
is called. That bug is now fixed in 1.8.1.
@enk0de Would you mind upgrading to this version and see if this fixes you problem?
from liveblocks.
hi! i'm really impressed with your amazing support and willingness to solve problems. I don't think I've ever seen such a quick response and enthusiastic willingness to solve problems in the GitHub community.
Thank you so much for your quick response and subsequent release with the bug fix. I'm looking forward to trying out your 1.8.1 release!
from liveblocks.
Hi @enk0de β thanks for opening this bug report. Just to make sure we correctly understand you... what does your expected vs actual undo stack look like in this example?
Also, have your tried upgrading to the latest version of Liveblocks? There have been a few small updates to the undo stack internals since 0.17.
from liveblocks.
Hi @nvie. first of all, i apologize for making confusion due to lack of explanation.
Before further explanation, I would like to inform you of changes to the issue contents. The version of @liveblocks/client that i am using is 1.7.1 not 0.17.1.
I am suffering 2 issues that i found.
- History disappears when i use history.pause/resume in batch callback
- History disappears intermittently
[1. History disappears when i use history.pause/resume in batch callback]
The code described below is like pseudocode, with details omitted to help understand the context.
Let's say we have two functions.
First one is
class CanvasService {
private liveNodes: LiveMap<string, LiveNode>;
...
public addNodes(
nodes: Node[]
) {
**this.room.history.pause();**
nodes.forEach((node) => this.liveNodes.set(node.id, node));
**this.room.history.resume();**
}
}
Second one is
function addNodesAndDoSomething() {
liveblocksService.batch(() => {
canvasService.addNodes([~~~~]);
// do something
})
}
when i call addNodesAndDoSomething()
, All history accumulated before calling this function will be lost.
[2. History disappears intermittently]
I didn't know exactly why or in what cases it happens. But I found a way to reproduce it to some extent.
we are managing selectedNodeIDs
in LiveBlocks Presence. so, when user select a node, application will update presence with updatePresence()
liveblocks api.
In the following way.
updatePresence({
selectedNodeIDs
}, {
addToHistory: true
});
and also we pass an object called { addToHistory: true } as the second argument to record selectedNodeIDs as history so that undo and redo can be performed.
At this time, if i call updatePresence({selectedNodeIDs}, {addToHistory:true})
twice with the exact same first argument value (selectedNodeIDs), suddenly history disappears. and undo/redo doesn't work.
from liveblocks.
All history accumulated before calling this function will be lost
Do you mean that the undo stack itself will be empty after calling addNodesAndDoSomething
β i.e. canUndo
becomes false
? That should definitely not happen, and I would consider that a bug for sure.
However, if I try the following on an arbitrary room:
room.batch(() => {
room.history.pause();
/* mutate room here arbitrarily */
room.history.resume();
});
β¦it seems to work as expected, and I don't see the history disappear. Can you share a bit more context that may be relevant for how your application is structured? Is there outer context maybe that also uses batches or that pauses history before reaching this snippet?
Regarding your second problem:
At this time, if i call
updatePresence({selectedNodeIDs}, {addToHistory:true})
twice with the exact same first argument value (selectedNodeIDs), suddenly history disappears. and undo/redo doesn't work.
That's certainly not right either! I could not replicate this behavior locally either, no matter what I tried. Is this code running in a specific batch
context, or after calling .pause()
? Would love to see an exact replication, any help in the form of a sequence of function calls that triggers this case would help debug this.
from liveblocks.
Related Issues (20)
- Collaborative text editor with Tiptap and Yjs not syncing HOT 3
- Second presence is "blinking" on the multiplayer text editor with Tiptap and Yjs HOT 2
- history.batch() is not working at async callback function. HOT 4
- Unable to select any text when using liveblocks with cursors HOT 1
- In the multiplayer text editor with Tiptap, is it possible to specify the cursor colors from the frontend?
- Anomalous behavior occurs when repeating removing and inserting between LiveLists HOT 10
- Multiplayer text editor duplicating initial content
- The `@liveblocks/node` client crashes when secret key is invalid HOT 4
- Improve pagination API for `client.getRooms()` endpoint in `@liveblocks/node` HOT 5
- Problem to fetch data from Liveblocks API when not setting a schema HOT 3
- Delete thread server API
- useDeleteThread HOT 1
- Deleting a room should delete associated threads and comments for GDPR
- `TypeError: storage.get(...).get(...).set is not a function` with useMutation and nested live object HOT 2
- YJS Integration Does not Appear to Fire Awareness `update` Event HOT 1
- Yjs image upload > 500KB raises websocket error with code 1005 HOT 2
- Minor type error in Awareness.states
- React `useThreads` incorrect usage of `useSyncExternalStoreWithSelector` triggers infinite re-renders HOT 1
- Fix to the error: Type `LiveObject<Layer>` does not satisfy the constraint `Lson` HOT 2
- Ensure useSyncExternalStoreWithSelector usage are stable
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liveblocks.