From 4dd4690de0e8aa4467abc9983d238132db68d832 Mon Sep 17 00:00:00 2001 From: William Moore Date: Thu, 28 Nov 2024 21:41:51 +0000 Subject: [PATCH] Fix repeated copy & paste of panel and inset --- src/js/views/util.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/js/views/util.js b/src/js/views/util.js index bc5f52d0..de248bd3 100644 --- a/src/js/views/util.js +++ b/src/js/views/util.js @@ -267,10 +267,6 @@ export function getRandomId() { return parseInt(Math.random() * RANDOM_NUMBER_RANGE); } -export function newIdFromRandomId(oldId) { - return parseInt((oldId * Math.PI) % RANDOM_NUMBER_RANGE); -} - export function updateRoiIds(panelsJson) { // If we copy and paste an inset panel AND it's corresponding panel with Rect, // we don't want changes in viewport/Rect to trigger changes in the panels they @@ -296,14 +292,15 @@ export function updateRoiIds(panelsJson) { let idsToUpdate = insetIdsFromPanels.filter(roiId => insetIdsFromShapes.includes(roiId)); // Update the IDs + let toAdd = getRandomId(); let updatedPanels = panelsJson.map(panelJson => { if (idsToUpdate.includes(panelJson.insetRoiId)) { - panelJson.insetRoiId = newIdFromRandomId(panelJson.insetRoiId); + panelJson.insetRoiId = (panelJson.insetRoiId + toAdd) % RANDOM_NUMBER_RANGE; } if (panelJson.shapes) { panelJson.shapes.forEach(shape => { if (idsToUpdate.includes(shape.id)) { - shape.id = newIdFromRandomId(shape.id); + shape.id = (shape.id + toAdd) % RANDOM_NUMBER_RANGE; } }); }