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)
- The Zustand middleware's `set` cannot safely be nested inside `batch`
- `Storage` type issue in `createRoomContext` in `liveblocks.config.ts` HOT 1
- Type error: Type `Storage` does not satisfy the constraint `LsonObject`. in `liveblocks.config.ts`
- Does `react-native-todo-list` need updating?
- Value changes many time in instantly when using the multiple move method of LiveList quickly HOT 3
- Removing thread metadata via `useThreadMetadata` results in metadata being removed followed by a quick flash of the old metadata
- Updating from v1.10.0 to v1.10.1 throws "process is not defined" error HOT 5
- process is undefined error on Vite project HOT 6
- EnsureJson is failing on a particular interface HOT 4
- Circular Reference in JSON HOT 2
- Using an async call in an event handler HOT 1
- RangeError: Maximum call stack size exceeded HOT 1
- Please explain how to update Yjs document from the backend with streaming AND keeping the formatting.
- Clients can crash in various ways if comment is deleted that an inbox notification still references
- Nested Rooms in React causing error HOT 8
- Add query regex filtering to metadata custom data
- liveblocksEnhancer does not mix in LiveblocksContext to the state HOT 1
- API endpoint for filtering threads by roomId prefix
- Bug: Comment Splits into Two When Typing in Vietnamese and Pressing Enter HOT 1
- OpenAPI spec is invalid
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.