debt - reduce usage of electron remote module

This commit is contained in:
Benjamin Pasero
2018-08-23 13:02:33 +02:00
parent 9a57f2e00b
commit 8f96ce69e2
8 changed files with 51 additions and 39 deletions

View File

@@ -7,7 +7,7 @@
const path = require('path');
const fs = require('fs');
const remote = require('electron').remote;
const ipc = require('electron').ipcRenderer;
function assign(destination, source) {
return Object.keys(source)
@@ -97,9 +97,9 @@ function main() {
window.addEventListener('keydown', function (e) {
const key = extractKey(e);
if (key === TOGGLE_DEV_TOOLS_KB) {
remote.getCurrentWebContents().toggleDevTools();
ipc.send('vscode:toggleDevTools');
} else if (key === RELOAD_KB) {
remote.getCurrentWindow().reload();
ipc.send('vscode:reloadWindow');
}
});

View File

@@ -6,7 +6,7 @@
'use strict';
import 'vs/css!./media/issueReporter';
import { shell, ipcRenderer, webFrame, remote, clipboard } from 'electron';
import { shell, ipcRenderer, webFrame, clipboard } from 'electron';
import { localize } from 'vs/nls';
import { $ } from 'vs/base/browser/dom';
import * as collections from 'vs/base/common/collections';
@@ -91,7 +91,7 @@ export class IssueReporter extends Disposable {
this.previewButton = new Button(document.getElementById('issue-reporter'));
ipcRenderer.on('issuePerformanceInfoResponse', (event, info) => {
ipcRenderer.on('vscode:issuePerformanceInfoResponse', (event, info) => {
this.logService.trace('issueReporter: Received performance data');
this.issueReporterModel.update(info);
this.receivedPerformanceInfo = true;
@@ -102,7 +102,7 @@ export class IssueReporter extends Disposable {
this.updatePreviewButtonState();
});
ipcRenderer.on('issueSystemInfoResponse', (event, info) => {
ipcRenderer.on('vscode:issueSystemInfoResponse', (event, info) => {
this.logService.trace('issueReporter: Received system data');
this.issueReporterModel.update({ systemInfo: info });
this.receivedSystemInfo = true;
@@ -111,9 +111,9 @@ export class IssueReporter extends Disposable {
this.updatePreviewButtonState();
});
ipcRenderer.send('issueSystemInfoRequest');
ipcRenderer.send('vscode:issueSystemInfoRequest');
if (configuration.data.issueType === IssueType.PerformanceIssue) {
ipcRenderer.send('issuePerformanceInfoRequest');
ipcRenderer.send('vscode:issuePerformanceInfoRequest');
}
this.logService.trace('issueReporter: Sent data requests');
@@ -308,7 +308,7 @@ export class IssueReporter extends Disposable {
const issueType = parseInt((<HTMLInputElement>event.target).value);
this.issueReporterModel.update({ issueType: issueType });
if (issueType === IssueType.PerformanceIssue && !this.receivedPerformanceInfo) {
ipcRenderer.send('issuePerformanceInfoRequest');
ipcRenderer.send('vscode:issuePerformanceInfoRequest');
}
this.updatePreviewButtonState();
this.render();
@@ -384,14 +384,14 @@ export class IssueReporter extends Disposable {
this.previewButton.onDidClick(() => this.createIssue());
this.addEventListener('disableExtensions', 'click', () => {
ipcRenderer.send('workbenchCommand', 'workbench.action.reloadWindowWithExtensionsDisabled');
ipcRenderer.send('vscode:workbenchCommand', 'workbench.action.reloadWindowWithExtensionsDisabled');
});
this.addEventListener('disableExtensions', 'keydown', (e: KeyboardEvent) => {
e.stopPropagation();
if (e.keyCode === 13 || e.keyCode === 32) {
ipcRenderer.send('workbenchCommand', 'workbench.extensions.action.disableAll');
ipcRenderer.send('workbenchCommand', 'workbench.action.reloadWindow');
ipcRenderer.send('vscode:workbenchCommand', 'workbench.extensions.action.disableAll');
ipcRenderer.send('vscode:workbenchCommand', 'workbench.action.reloadWindow');
}
});
@@ -400,7 +400,7 @@ export class IssueReporter extends Disposable {
// Cmd/Ctrl+Enter previews issue and closes window
if (cmdOrCtrlKey && e.keyCode === 13) {
if (this.createIssue()) {
remote.getCurrentWindow().close();
ipcRenderer.send('vscode:closeIssueReporter');
}
}

View File

@@ -7,7 +7,7 @@
const path = require('path');
const fs = require('fs');
const remote = require('electron').remote;
const ipc = require('electron').ipcRenderer;
function assign(destination, source) {
return Object.keys(source)
@@ -141,9 +141,9 @@ function main() {
window.addEventListener('keydown', function (e) {
const key = extractKey(e);
if (key === TOGGLE_DEV_TOOLS_KB) {
remote.getCurrentWebContents().toggleDevTools();
ipc.send('vscode:toggleDevTools');
} else if (key === RELOAD_KB) {
remote.getCurrentWindow().reload();
ipc.send('vscode:reloadWindow');
}
});

View File

@@ -198,7 +198,7 @@ export function startup(data: ProcessExplorerData): void {
applyZoom(data.zoomLevel);
// Map window process pids to titles, annotate process names with this when rendering to distinguish between them
ipcRenderer.on('windowsInfoResponse', (event, windows) => {
ipcRenderer.on('vscode:windowsInfoResponse', (event, windows) => {
mapPidToWindowTitle = new Map<number, string>();
windows.forEach(window => mapPidToWindowTitle.set(window.pid, window.title));
});

View File

@@ -79,11 +79,6 @@
</body>
<script>
const electron = require('electron');
const shell = electron.shell;
const ipc = electron.ipcRenderer;
const remote = electron.remote;
const currentWindow = remote.getCurrentWindow();
function promptForCredentials(data) {
return new Promise((c, e) => {