From 82df8a6add52572f54884424a4f4b8048384502a Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Fri, 2 Aug 2019 16:21:32 +0200 Subject: [PATCH 1/3] PROEDITOR-27: Try to preserve the window. When opening sketches. Rules: - If `sketch` is missing from the URL, we reuse the same window. - NOOP, if we try to open the currently opened sketch. - Otherwise, use the existing logic: open sketch in a new window. Signed-off-by: Akos Kitta --- .../browser/arduino-frontend-contribution.tsx | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx index 63f4930a..314956fb 100644 --- a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx +++ b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx @@ -19,7 +19,7 @@ import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service import { SketchFactory } from './sketch-factory'; import { ArduinoToolbar } from './toolbar/arduino-toolbar'; import { EditorManager, EditorMainMenu } from '@theia/editor/lib/browser'; -import { ContextMenuRenderer, OpenerService, Widget, StatusBar, ShellLayoutRestorer, StatusBarAlignment } from '@theia/core/lib/browser'; +import { ContextMenuRenderer, OpenerService, Widget, StatusBar, ShellLayoutRestorer, StatusBarAlignment, LabelProvider } from '@theia/core/lib/browser'; import { OpenFileDialogProps, FileDialogService } from '@theia/filesystem/lib/browser/file-dialog'; import { FileSystem, FileStat } from '@theia/filesystem/lib/common'; import { ArduinoToolbarContextMenu } from './arduino-file-menu'; @@ -113,6 +113,9 @@ export class ArduinoFrontendContribution implements TabBarToolbarContribution, C @inject(ShellLayoutRestorer) protected readonly layoutRestorer: ShellLayoutRestorer; + @inject(LabelProvider) + protected readonly labelProvider: LabelProvider; + protected boardsToolbarItem: BoardsToolBarItem | null; protected wsSketchCount: number = 0; @@ -375,9 +378,21 @@ export class ArduinoFrontendContribution implements TabBarToolbarContribution, C } protected async openSketchFilesInNewWindow(uri: string) { - const location = new URL(window.location.href); - location.searchParams.set('sketch', uri); - this.windowService.openNewWindow(location.toString()); + const url = new URL(window.location.href); + const currentSketch = url.searchParams.get('sketch'); + // Nothing to do if we want to open the same sketch which is already opened. + if (!!currentSketch && new URI(currentSketch).toString() === new URI(uri).toString()) { + this.messageService.info(`The '${this.labelProvider.getLongName(new URI(uri))}' is already opened.`); + // NOOP. + return; + } + // Preserve the current window if the `sketch` is not in the `searchParams`. + url.searchParams.set('sketch', uri); + if (!currentSketch) { + setTimeout(() => window.location.href = url.toString(), 100); + return; + } + this.windowService.openNewWindow(url.toString()); } async openSketchFiles(uri: string) { From ded838b4e84ebf56341e18c1e756e04c08099303 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Fri, 2 Aug 2019 16:24:28 +0200 Subject: [PATCH 2/3] Fixed the `preloadTemplate` for electron. Signed-off-by: Akos Kitta --- arduino-ide-electron/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arduino-ide-electron/package.json b/arduino-ide-electron/package.json index dac2592d..f3392091 100644 --- a/arduino-ide-electron/package.json +++ b/arduino-ide-electron/package.json @@ -39,11 +39,11 @@ "editor.autoSave": "on" } } - } - }, - "generator": { - "config": { - "preloadTemplate": "
" + }, + "generator": { + "config": { + "preloadTemplate": "
" + } } } } \ No newline at end of file From af9b9fbeab79188dc4babc1da60afb80c3d5e7a8 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Mon, 5 Aug 2019 13:17:59 +0200 Subject: [PATCH 3/3] Yet another attempt to fix timeout issues on Azure. ``` info There appears to be trouble with your network connection. Retrying... error An unexpected error occurred: "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.2.tgz: ESOCKETTIMEDOUT". info If you think this is a bug, please open a bug report with the information provided in "D:\\a\\1\\s\\yarn-error.log". ``` Signed-off-by: Akos Kitta --- electron/packager/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/electron/packager/index.js b/electron/packager/index.js index dbb1c5c5..0307df8c 100644 --- a/electron/packager/index.js +++ b/electron/packager/index.js @@ -66,7 +66,7 @@ //-------------------------------------------------------------------------------------------------+ // Rebuild the extension with the copied `yarn.lock`. It is a must to use the same Theia versions. | //-------------------------------------------------------------------------------------------------+ - exec(`yarn --cwd ${path('..', workingCopy)}`, 'Building the Arduino Theia extensions'); + exec(`yarn --network-timeout 1000000 --cwd ${path('..', workingCopy)}`, 'Building the Arduino Theia extensions'); // Collect all unused dependencies by the backend. We have to remove them from the electron app. // The `bundle.js` already contains everything we need for the frontend. // We have to do it before changing the dependencies to `local-path`. @@ -98,8 +98,8 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()} //-------------------------------------------------------------------------------------------+ // Install all private and public dependencies for the electron application and build Theia. | //-------------------------------------------------------------------------------------------+ - exec(`yarn --cwd ${path('..', 'build')}`, 'Installing dependencies'); - exec(`yarn --cwd ${path('..', 'build')} build${release ? ':release' : ''}`, 'Building the Arduino-PoC application'); + exec(`yarn --network-timeout 1000000 --cwd ${path('..', 'build')}`, 'Installing dependencies'); + exec(`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} build${release ? ':release' : ''}`, 'Building the Arduino-PoC application'); //------------------------------------------------------------------------------+ // Create a throw away dotenv file which we use to feed the builder with input. | @@ -115,7 +115,7 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()} //-----------------------------------+ // Package the electron application. | //-----------------------------------+ - exec(`yarn --cwd ${path('..', 'build')} package`, `Packaging your Arduino-PoC application`); + exec(`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} package`, `Packaging your Arduino-PoC application`); echo(`🎉 Success. Your application is at: ${path('..', 'build', 'dist')}`); restore();