From 380b6bd9852442ee0b9db43d798efda69578c351 Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Wed, 9 Apr 2025 10:51:57 +0200 Subject: [PATCH 1/4] Forcing stop when switching to File Manager. Signed-off-by: ubi de feo --- ui/arduino/store.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/arduino/store.js b/ui/arduino/store.js index 5b8e45d..29aa556 100644 --- a/ui/arduino/store.js +++ b/ui/arduino/store.js @@ -111,6 +111,9 @@ async function store(state, emitter) { } emitter.emit('refresh-files') } + if(view === 'file-manager') { + emitter.emit('stop') + } state.view = view emitter.emit('render') updateMenu() From 03cc8934deac6d389ff558737af569b3adfcaab6 Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Wed, 9 Apr 2025 10:55:48 +0200 Subject: [PATCH 2/4] Comments and logging cleanup. Signed-off-by: ubi de feo --- index.js | 4 ++-- ui/arduino/store.js | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index a5658cd..a16ea09 100644 --- a/index.js +++ b/index.js @@ -65,11 +65,11 @@ app.on('ready', () => { createWindow() win.on('focus', () => { - console.log("win focus") + // console.log("win focus") }) win.on('blur', () => { - console.log("win blur") + // console.log("win blur") }) }) diff --git a/ui/arduino/store.js b/ui/arduino/store.js index 29aa556..95ea087 100644 --- a/ui/arduino/store.js +++ b/ui/arduino/store.js @@ -24,7 +24,6 @@ async function confirmDialog(msg, cancelMsg, confirmMsg) { cancelId: 1, message: msg }) - console.log('confirm', response) return Promise.resolve(response) } @@ -103,8 +102,8 @@ async function store(state, emitter) { } emitter.emit('render') }) + emitter.on('change-view', (view) => { - if (state.view === 'file-manager') { if (view != state.view) { state.selectedFiles = [] @@ -161,7 +160,7 @@ async function store(state, emitter) { cancelId: 0, message: "Could not connect to the board. Reset it and try again." }) - console.log('Reset request acknowledged', response) + // console.log('Reset request acknowledged', response) emitter.emit('connection-timeout') }, 3500) try { @@ -1197,7 +1196,7 @@ async function store(state, emitter) { && f.source == selectedFile.source && f.parentFolder == selectedFile.parentFolder }) - console.log('already open', alreadyOpen) + // console.log('already open', alreadyOpen) if (!alreadyOpen) { // This file is not open yet, @@ -1547,19 +1546,16 @@ async function store(state, emitter) { function filterDoubleRun(onlySelected = false) { if (preventDoubleRun) return - console.log('>>> RUN CODE ACTUAL <<<') emitter.emit('run', onlySelected) timedReset() } function runCode() { - console.log('>>> RUN CODE REQUEST <<<') if (canExecute({ view: state.view, isConnected: state.isConnected })) { filterDoubleRun() } } function runCodeSelection() { - console.log('>>> RUN CODE REQUEST <<<') if (canExecute({ view: state.view, isConnected: state.isConnected })) { filterDoubleRun(true) } @@ -1638,7 +1634,6 @@ async function store(state, emitter) { // LEAK > listeners keep getting added and not removed when tabs are closed // additionally I found that closing a tab has actually added an extra listener newFile.editor.onChange = function() { - console.log('editor has changes') newFile.hasChanges = true emitter.emit('render') } From 78afa75062b9e4f4d61d3fb38235d49048ff389d Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Wed, 9 Apr 2025 16:14:49 +0200 Subject: [PATCH 3/4] Addressed review feedback. Signed-off-by: ubi de feo --- index.js | 2 -- ui/arduino/store.js | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index a16ea09..3b3a0fd 100644 --- a/index.js +++ b/index.js @@ -65,11 +65,9 @@ app.on('ready', () => { createWindow() win.on('focus', () => { - // console.log("win focus") }) win.on('blur', () => { - // console.log("win blur") }) }) diff --git a/ui/arduino/store.js b/ui/arduino/store.js index 95ea087..e463685 100644 --- a/ui/arduino/store.js +++ b/ui/arduino/store.js @@ -160,7 +160,6 @@ async function store(state, emitter) { cancelId: 0, message: "Could not connect to the board. Reset it and try again." }) - // console.log('Reset request acknowledged', response) emitter.emit('connection-timeout') }, 3500) try { @@ -1196,7 +1195,6 @@ async function store(state, emitter) { && f.source == selectedFile.source && f.parentFolder == selectedFile.parentFolder }) - // console.log('already open', alreadyOpen) if (!alreadyOpen) { // This file is not open yet, @@ -1628,8 +1626,10 @@ async function store(state, emitter) { } const tabExists = state.openFiles.find(f => f.parentFolder === newFile.parentFolder && f.fileName === newFile.fileName && f.source === newFile.source) if (tabExists || fullPathExists) { - const confirmation = confirmDialog(`File ${newFile.fileName} already exists on ${source}. Please choose another name.`, 'OK') - return false + const confirmation = await confirmDialog(`File ${newFile.fileName} already exists on ${source}. Please choose another name.`, 'OK') + if (!confirmation) { + return false + } } // LEAK > listeners keep getting added and not removed when tabs are closed // additionally I found that closing a tab has actually added an extra listener From 110193a32e1b03e81b4c2b5eafe62e6f48ef9270 Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Wed, 9 Apr 2025 18:56:57 +0200 Subject: [PATCH 4/4] Amended return false on duplicate tab alert. Signed-off-by: ubi de feo --- ui/arduino/store.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ui/arduino/store.js b/ui/arduino/store.js index e463685..04889b4 100644 --- a/ui/arduino/store.js +++ b/ui/arduino/store.js @@ -1627,9 +1627,7 @@ async function store(state, emitter) { const tabExists = state.openFiles.find(f => f.parentFolder === newFile.parentFolder && f.fileName === newFile.fileName && f.source === newFile.source) if (tabExists || fullPathExists) { const confirmation = await confirmDialog(`File ${newFile.fileName} already exists on ${source}. Please choose another name.`, 'OK') - if (!confirmation) { - return false - } + return false } // LEAK > listeners keep getting added and not removed when tabs are closed // additionally I found that closing a tab has actually added an extra listener