DRAFT: Adjust autosave debounce
Context
There is a need to improve/optimize the number of requests that we are sending to Ketida's server when it comes to updating a chapter's content. Currently, we are making use of the event that the editor broadcasts, which provides all the changes made to a chapter's content by an editor. This event is wrapped inside a debounce
function which acts like a buffer
between what it is typed by a user and how many change requests sent to the server.
Typically, the timeframe argument of the debounce
method should be 500ms
but for our case is 50ms
. This configuration could potentially increase the server load and in a environment with a high number of concurrent users could lead to performance issues.
The root cause of this decision, 50ms
instead of 500ms
or higher, is due to the problematic correlation between the title of a chapter and its content. Currently, if a user wants to provide a title, or change the title of a chapter, then this action should happen from within the editor. However, each chapter's title is also displayed on a panel that exists at the left of the editing area, which also presents all the existing chapters of a book. When a title is changed/created as part of the chapter's content, if the time factor of the debounce
function ,described above, is high/higher then this will lead to an inconsistency between the title which exists in the editing area and the title which will be displayed on the panel area at the left of the editing area.
All the above explains why this is a trade-off situation with no easy solution.
Proposal
- Extract chapter's title and decouple it from the content to its own input field. The title can be added as the first element of a chapter's content during the export/preview process. During the editing phase, the title will only be displayed on the panel at the left of the editing area and from there and only there a user will be able to change its value. (requires some effort to be implemented but it is the cleanest solution)
- Introduce state to the
Producer
UI which will act as a middleware between the title exists inside the content and the title on the panel at the left of the editing area. (requires more or less the same effort as the above but will increase the complexity as managing of state should be implemented)