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

Commit

Permalink
Add onNewWindow event
Browse files Browse the repository at this point in the history
Former-commit-id: 321e595 [formerly 321e595 [formerly a8c5cf2]]
Former-commit-id: 38c19c083d2c4bb777c7302c35617cca1ebc8b76
Former-commit-id: 4f1200e
  • Loading branch information
sentialx committed Jul 25, 2018
1 parent c2eb37a commit 2e626de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/app/components/Page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default class extends React.Component<{ page: Page }, {}> {
this.webview.addEventListener('dom-ready', this.onDomReady);
this.webview.addEventListener('enter-html-full-screen', this.onFullscreenEnter);
this.webview.addEventListener('leave-html-full-screen', this.onFullscreenLeave);
this.webview.addEventListener('new-window', this.onNewWindow);

// Custom event: fires when webview URL changes.
this.onURLChange = setInterval(() => {
Expand All @@ -54,12 +55,21 @@ export default class extends React.Component<{ page: Page }, {}> {
this.webview.removeEventListener('page-favicon-updated', this.onPageFaviconUpdated);
this.webview.removeEventListener('enter-html-full-screen', this.onFullscreenEnter);
this.webview.removeEventListener('leave-html-full-screen', this.onFullscreenLeave);
this.webview.removeEventListener('new-window', this.onNewWindow);

clearInterval(this.onURLChange);

Store.isFullscreen = false;
}

public onNewWindow = (e: Electron.NewWindowEvent) => {
if (e.disposition === 'new-window' || e.disposition === 'foreground-tab') {
Store.getCurrentWorkspace().addTab(e.url, true);
} else if (e.disposition === 'background-tab') {
Store.getCurrentWorkspace().addTab(e.url, false);
}
};

public onContextMenu = (e: Electron.Event, params: Electron.ContextMenuParams) => {
requestAnimationFrame(() => {
Store.pageMenu.toggle(true);
Expand Down
1 change: 0 additions & 1 deletion src/newtab/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { getWeather } from '../../utils/weather';
import { getNews } from '../../utils/news';
import News from '../News';
import WeatherCard from '../WeatherCard';
import PatreonsCard from '../PatreonsCard';

import {
TimeUnit, TemperatureUnit, WeatherLanguages, Countries,
Expand Down

0 comments on commit 2e626de

Please sign in to comment.