Open Solvengo opened 3 years ago
I fixed it by adding this to the loadFromStorage() method. This prevents the code from pushing the saved array to the original array twice.
if (
this.canvasWhiteboardComponent.getDrawingHistory().length !=
updates.length
) {
this.canvasWhiteboardService.drawCanvas(updates);
}
I also added this to the savetoStorage() method.
const updates: Array<CanvasWhiteboardUpdate> = this.canvasWhiteboardComponent.getDrawingHistory();
for (const u of updates) {
u.x = Number(u.x);
u.y = Number(u.y);
}
I'll do a pull request later this day.
A problem occurs when the drawing gets saved to Sessionstorage, or in our case to a string variable. After an initial save, when the drawing is loaded it can't be saved again. update.stringify() throws an TypeError "this.x.toFixed()". I noticed that the length of the updates arrays doubles. What causes this? Did you forget to reset the array after an initial update.stringify()? Or does this.canvasWhiteboardService.drawCanvas(updates) add the drawing twice which causes problems?