diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index f7dd0764..880f8479 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -80,6 +80,7 @@ class NoteList extends React.Component { this.getViewType = this.getViewType.bind(this) this.restoreNote = this.restoreNote.bind(this) this.copyNoteLink = this.copyNoteLink.bind(this) + this.navigate = this.navigate.bind(this) // TODO: not Selected noteKeys but SelectedNote(for reusing) this.state = { @@ -98,6 +99,7 @@ class NoteList extends React.Component { ee.on('list:isMarkdownNote', this.alertIfSnippetHandler) ee.on('import:file', this.importFromFileHandler) ee.on('list:jump', this.jumpNoteByHash) + ee.on('list:navigate', this.navigate) } componentWillReceiveProps (nextProps) { @@ -687,6 +689,16 @@ class NoteList extends React.Component { return copy(noteLink) } + navigate (sender, pathname) { + const { router } = this.context + router.push({ + pathname, + query: { + // key: noteKey + } + }) + } + save (note) { const { dispatch } = this.props dataApi diff --git a/lib/touchbar-menu.js b/lib/touchbar-menu.js index bb7ae79a..fa2fae9e 100644 --- a/lib/touchbar-menu.js +++ b/lib/touchbar-menu.js @@ -1,19 +1,33 @@ const {TouchBar} = require('electron') const {TouchBarButton, TouchBarSpacer} = TouchBar +const mainWindow = require('./main-window') const allNotes = new TouchBarButton({ label: '📒', - click: () => {} + click: () => { + mainWindow.webContents.send('list:navigate', '/home') + } }) const starredNotes = new TouchBarButton({ label: '⭐️', - click: () => {} + click: () => { + mainWindow.webContents.send('list:navigate', '/starred') + } }) const trash = new TouchBarButton({ label: '🗑', - click: () => {} + click: () => { + mainWindow.webContents.send('list:navigate', '/trashed') + } +}) + +const newNote = new TouchBarButton({ + label: '✎', + click: () => { + mainWindow.webContents.send('top:new-note') + } }) module.exports = new TouchBar([ @@ -21,6 +35,8 @@ module.exports = new TouchBar([ new TouchBarSpacer({size: 'small'}), starredNotes, new TouchBarSpacer({size: 'small'}), - trash + trash, + new TouchBarSpacer({size: 'large'}), + newNote ])