From f3370242bfa41eb69cdb2afd901964c857ed035d Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Fri, 13 Oct 2017 13:12:41 +0900 Subject: [PATCH] Add conditions to hide pin from /home, /starred or /trash --- browser/components/NoteItem.js | 4 ++-- browser/main/NoteList/index.js | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/browser/components/NoteItem.js b/browser/components/NoteItem.js index ce209471..b6e066e0 100644 --- a/browser/components/NoteItem.js +++ b/browser/components/NoteItem.js @@ -45,7 +45,7 @@ const TagElementList = (tags) => { * @param {Function} handleDragStart * @param {string} dateDisplay */ -const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleNoteContextMenu, handleDragStart }) => ( +const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleDragStart, handleNoteContextMenu, pathname }) => (
: '' } - {note.isPinned + {note.isPinned && !pathname.match(/\/home|\/starred|\/trash/) ? : '' } {note.type === 'MARKDOWN_NOTE' diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 9c1b30c6..dfd9a74e 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -285,10 +285,13 @@ class NoteList extends React.Component { } sortByPin (unorderedNotes) { - const { data, params } = this.props + const { data, params, location } = this.props let storageKey = params.storageKey let folderKey = params.folderKey let storage = data.storageMap.get(storageKey) + if (location.pathname.match(/\/home|\/starred|\/trash/)){ + return unorderedNotes + } if (storage === undefined) return [] let folder = _.find(storage.folders, {key: folderKey}) @@ -431,18 +434,23 @@ class NoteList extends React.Component { } handleNoteContextMenu (e, uniqueKey) { + const { location } = this.props let targetIndex = _.findIndex(this.notes, (note) => { return note != null && uniqueKey === `${note.storage}-${note.key}` }) let note = this.notes[targetIndex] const label = note.isPinned ? 'Remove pin' : 'Pin to Top' + let menu = new Menu() menu.append(new MenuItem({ label: label, click: (e) => this.handlePinToTop(e, uniqueKey) })) - menu.popup() + + if (!location.pathname.match(/\/home|\/starred|\/trash/)){ + menu.popup() + } } handlePinToTop (e, uniqueKey) { @@ -525,6 +533,7 @@ class NoteList extends React.Component { handleNoteClick={this.handleNoteClick.bind(this)} handleNoteContextMenu={this.handleNoteContextMenu.bind(this)} handleDragStart={this.handleDragStart.bind(this)} + pathname={location.pathname} /> ) }