Skip to content

Commit

Permalink
feat: add some actions to menu
Browse files Browse the repository at this point in the history
  • Loading branch information
sentialx committed Sep 30, 2019
1 parent c652eb2 commit c71ffa8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/renderer/views/menu/components/QuickMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { icons } from '~/renderer/constants';
import store from '../../store';
import { ipcRenderer } from 'electron';
import { NEWTAB_URL } from '~/constants/tabs';

const changeContent = () => () => {
// store.overlay.currentContent = content;
Expand Down Expand Up @@ -60,8 +61,12 @@ const onIncognitoClick = () => {
ipcRenderer.send('create-window', true);
};

const addTab = (url: string) => () => {
ipcRenderer.send(`view-create-${store.windowId}`, { url, active: true });
store.hide();
};

export const QuickMenu = observer(() => {
// const invert = store.theme['overlay.foreground'] === 'light';
const invert = true;

return (
Expand Down Expand Up @@ -112,7 +117,7 @@ export const QuickMenu = observer(() => {
)}
</Actions>
<MenuItems>
<MenuItem>
<MenuItem onClick={addTab(NEWTAB_URL)}>
<Icon icon={icons.tab} />
<MenuItemTitle>New tab</MenuItemTitle>
<Shortcut>Ctrl+T</Shortcut>
Expand All @@ -128,24 +133,24 @@ export const QuickMenu = observer(() => {
<Shortcut>Ctrl+Shift+N</Shortcut>
</MenuItem>
<Line />
<MenuItem arrow>
<MenuItem onClick={addTab('wexond://history')} arrow>
<Icon icon={icons.history} />
<MenuItemTitle>History</MenuItemTitle>
</MenuItem>
<MenuItem arrow>
<MenuItem onClick={addTab('wexond://bookmarks')} arrow>
<Icon icon={icons.bookmarks} />
<MenuItemTitle>Bookmarks</MenuItemTitle>
</MenuItem>
<MenuItem>
<MenuItem onClick={addTab('wexond://downloads')}>
<Icon icon={icons.download} />
<MenuItemTitle>Downloads</MenuItemTitle>
</MenuItem>
<Line />
<MenuItem>
<MenuItem onClick={addTab('wexond://settings')}>
<Icon icon={icons.settings} />
<MenuItemTitle>Settings</MenuItemTitle>
</MenuItem>
<MenuItem>
<MenuItem onClick={addTab('wexond://extensions')}>
<Icon icon={icons.extensions} />
<MenuItemTitle>Extensions</MenuItemTitle>
</MenuItem>
Expand Down
9 changes: 8 additions & 1 deletion src/renderer/views/menu/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export class Store {
@observable
public id = remote.getCurrentWebContents().id;

@observable
public windowId = remote.getCurrentWindow().id;

public constructor() {
ipcRenderer.on('visible', (e, flag) => {
this.visible = flag;
Expand All @@ -25,7 +28,7 @@ export class Store {
window.addEventListener('blur', () => {
if (this.visible) {
setTimeout(() => {
ipcRenderer.send(`hide-${this.id}`);
this.hide();
});
}
});
Expand All @@ -38,6 +41,10 @@ export class Store {
});
}

public hide() {
ipcRenderer.send(`hide-${this.id}`);
}

public updateSettings(newSettings: ISettings) {
this.settings = { ...this.settings, ...newSettings };

Expand Down

0 comments on commit c71ffa8

Please sign in to comment.