From 27c27f2e0457eed1d1cea1e4e7f5f862d8eeff29 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Tue, 19 May 2020 05:34:00 +0200 Subject: [PATCH] Reorder services without switching to the reordered service --- resources/js/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/js/index.js b/resources/js/index.js index f2f266e..046ebc0 100644 --- a/resources/js/index.js +++ b/resources/js/index.js @@ -23,6 +23,7 @@ let emptyPage; let urlPreview; let lastDragPosition; +let oldActiveService; // For service reordering // Service context menu function openServiceContextMenu(event, serviceId) { @@ -216,16 +217,19 @@ ipcRenderer.on('reorderService', (e, serviceId, targetId) => { const oldServices = services; services = []; + let newId = targetId; + for (let i = 0; i < targetId; i++) { if (i !== serviceId) { services.push(oldServices[i]); + if (i === oldActiveService) newId = i; } } services.push(oldServices[serviceId]); - const newId = services.length - 1; for (let i = targetId; i < oldServices.length; i++) { if (i !== serviceId) { services.push(oldServices[i]); + if (i === oldActiveService) newId = i; } } @@ -354,6 +358,7 @@ function resetDrag() { function reorderService(serviceId, targetId) { console.log('Reordering service', serviceId, targetId); if (targetId >= 0) { + oldActiveService = selectedService; setActiveService(null); ipcRenderer.send('reorderService', serviceId, targetId); }