From b346a4a7bd893985fb8a390797ece192bf099770 Mon Sep 17 00:00:00 2001 From: Pedro Beschorner Marin Date: Tue, 5 Oct 2021 20:00:41 -0300 Subject: [PATCH] fix(canvases): empty canvas force clean Add empty canvases to listen for all slide changes and avoid carrying the previous slide annotations to the following one. --- src/utils/builder.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/utils/builder.js b/src/utils/builder.js index 4244b576..7ecc453a 100644 --- a/src/utils/builder.js +++ b/src/utils/builder.js @@ -255,7 +255,6 @@ const buildCanvases = (group, slides) => { canvases = group.map(canvas => { const canvasAttr = getAttr(canvas); const canvasId = getId(canvasAttr.id); - const { timestamp } = slides.find(slide => slide.id === canvasId); let data = canvas.g.map(g => { const drawAttr = getAttr(g); @@ -310,11 +309,25 @@ const buildCanvases = (group, slides) => { return { data, id: canvasId, - timestamp, }; }); } + slides.forEach((slide, index) => { + const found = canvases.find(canvas => canvas.id === slide.id); + if (found) { + canvases[index].timestamp = slide.timestamp; + } else { + const canvas = { + data: [], + id: slide.id, + timestamp: slide.timestamp, + }; + + canvases.splice(index, 0, canvas); + } + }); + return canvases; };