Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
fix: move opening of url to main process
Browse files Browse the repository at this point in the history
  • Loading branch information
tilmx authored and lkuechler committed Jun 6, 2018
1 parent e2eac1b commit 72805e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/container/chrome/chrome-container.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -74,9 +76,12 @@ export const ChromeContainer = MobxReact.inject('store')(
<BugReport
title="Found a bug?"
onClick={() => {
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}
Expand Down
8 changes: 7 additions & 1 deletion src/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -369,6 +369,12 @@ async function createWindow(): Promise<void> {
});
});
});

break;
}

case ServerMessageType.OpenExternalURL: {
shell.openExternal(message.payload);
}
}
});
Expand Down
3 changes: 3 additions & 0 deletions src/message/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -110,6 +111,7 @@ export type ServerMessage =
| ExportSketch
| HighlightElement
| Log
| OpenExternalURL
| OpenFileRequest
| OpenFileResponse
| PageChange
Expand Down Expand Up @@ -191,6 +193,7 @@ export type Duplicate = EmptyEnvelope<ServerMessageType.Duplicate>;
export type DuplicatePageElement = Envelope<ServerMessageType.DuplicateElement, string>;
// tslint:disable-next-line:no-any
export type Log = Envelope<ServerMessageType.Log, any>;
export type OpenExternalURL = Envelope<ServerMessageType.OpenExternalURL, string>;
export type OpenFileRequest = EmptyEnvelope<ServerMessageType.OpenFileRequest>;
export type OpenFileResponse = Envelope<ServerMessageType.OpenFileResponse, Types.ProjectPayload>;
export type PageChange = Envelope<ServerMessageType.PageChange, Types.PageChangePayload>;
Expand Down

0 comments on commit 72805e2

Please sign in to comment.