Hello, I am trying to create an Undo/Redo function with editable table cells. I have some ideas on how to achieve it, but there are some issues I don't know how to handle.
*Save the changes
I can save the changes from the changesetArray
into a variable as an array, thus creating a 'history'.
*Undo/Redo Changes
I can assign a variable as the data source for my table and assign the last element of the history to that variable.
*Database
My issue is here, as saving every change to the database is not feasible due to, how to manage the history of that database and undoing them. If a record was added, I would have to delete it.
The most "optimal" solution would be to determine a save period or an event that saves these changes and clears the history, this way all changes will be stored as arrays, but there is a risk of losing changes made if, for some reason, that event does not execute (user disconnects, refreshing page, etc).
*Use case
My app is a Quotation Tool, and such quotations have several amount of data being edited, also i have implemented a copy/paste function between tables and i want users to be able to undo such actions. (Working with RetoolDB, cloud version)
Is there any recommended practice when dealing with these situations? Any suggestions are appreciated, if more information or context is needed, feel free to ask for it. Thank you.