Closed atheler closed 10 months ago
I updated the code for the use of the new YRoomMessage.has_edits
flag from Adding has_edits Flag to YRoomMessage. The changes seem to work nicely together inside my current Django application and the unnecessary autosaves disappeared. The room forgetting has also been moved inside the cleanup task's remove_room method see discussion.
Why was the forward reference to YRoomChannelConsumer
removed?
Why was the forward reference to YRoomChannelConsumer removed?
Sorry, bad rebase when I tried to fix the style of the forward ref (black
didn't like it).
Implementing autosave functionality which snapshots a room after a period of editing inactivity.
Motivation
A collaborative document gets stored in a database with additional versioning. It would be nice if the stored snapshots correspond to a stable state of the document. That is, in between edits.
Changes
A new
AUTOSAVE_DELAY
setting was added which controls the debounce delay per room. This is turned off by default.YROOM_SETTINGS = {'my-document': {'AUTOSAVE_DELAY': 10.0}}
An additional
Autosave
object inside theYRoomChannelConsumer
handles the debouncing and triggers the snapshots. This object spawns a waiter task for each room similar to the cleanup tasks ofYRoomChannelConsumer
.Issue / Open Question
In order for this to work proper editing messages need to be distinguished from awareness / background messages. Unfortunately I am not familiar enough with the
lib0 encoding
scheme. For now a simple size threshold is in place inside Autosave.nudge_if_changed(). This needs refinement and I would be grateful for inputs pointing me in the right direction.Closing
Let me know what you think and thanks again to @stefanw for the great work!