From 72805e2a6cbdf53d52be7bf39016cf1c3993e691 Mon Sep 17 00:00:00 2001 From: Tilman Frick Date: Tue, 5 Jun 2018 23:26:27 +0200 Subject: [PATCH] fix: move opening of url to main process --- src/container/chrome/chrome-container.tsx | 13 +++++++++---- src/electron/main.ts | 8 +++++++- src/message/message.ts | 3 +++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/container/chrome/chrome-container.tsx b/src/container/chrome/chrome-container.tsx index d39df1fbf..e10ddf2bf 100644 --- a/src/container/chrome/chrome-container.tsx +++ b/src/container/chrome/chrome-container.tsx @@ -1,11 +1,13 @@ import * as AlvaUtil from '../../alva-util'; import { BugReport, Chrome, CopySize, ViewSwitch, ViewTitle } from '../../components'; -import * as Electron from 'electron'; +import { ServerMessageType } from '../../message'; import * as MobxReact from 'mobx-react'; import { OverviewSwitchContainer } from './overview-switch-container'; import * as React from 'react'; +import * as Sender from '../../message/client'; import { ViewStore } from '../../store'; import * as Types from '../../model/types'; +import * as uuid from 'uuid'; interface InjectedChromeContainerProps { store: ViewStore; @@ -74,9 +76,12 @@ export const ChromeContainer = MobxReact.inject('store')( { - Electron.shell.openExternal( - 'https://github.com/meetalva/alva/labels/type%3A%20bug' - ); + console.log('chrome-container started'); + Sender.send({ + type: ServerMessageType.OpenExternalURL, + id: uuid.v4(), + payload: 'https://github.com/meetalva/alva/labels/type%3A%20bug' + }); }} /> {props.children} diff --git a/src/electron/main.ts b/src/electron/main.ts index 09236417f..92e5063fd 100644 --- a/src/electron/main.ts +++ b/src/electron/main.ts @@ -2,7 +2,7 @@ import * as Analyzer from '../analyzer'; import { checkForUpdates } from './auto-updater'; import { Color } from '../components'; import { createCompiler } from '../compiler/create-compiler'; -import { app, BrowserWindow, dialog, screen } from 'electron'; +import { app, BrowserWindow, dialog, screen, shell } from 'electron'; import * as electronIsDev from 'electron-is-dev'; import * as Fs from 'fs'; import * as getPort from 'get-port'; @@ -369,6 +369,12 @@ async function createWindow(): Promise { }); }); }); + + break; + } + + case ServerMessageType.OpenExternalURL: { + shell.openExternal(message.payload); } } }); diff --git a/src/message/message.ts b/src/message/message.ts index 6c2df7cbe..2072db9d5 100644 --- a/src/message/message.ts +++ b/src/message/message.ts @@ -50,6 +50,7 @@ export enum ServerMessageType { ExportSketch = 'export-sketch', HighlightElement = 'highlight-element', Log = 'log', + OpenExternalURL = 'open-external-url', OpenFileRequest = 'open-file-request', OpenFileResponse = 'open-file-response', PageChange = 'page-change', @@ -110,6 +111,7 @@ export type ServerMessage = | ExportSketch | HighlightElement | Log + | OpenExternalURL | OpenFileRequest | OpenFileResponse | PageChange @@ -191,6 +193,7 @@ export type Duplicate = EmptyEnvelope; export type DuplicatePageElement = Envelope; // tslint:disable-next-line:no-any export type Log = Envelope; +export type OpenExternalURL = Envelope; export type OpenFileRequest = EmptyEnvelope; export type OpenFileResponse = Envelope; export type PageChange = Envelope;