Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add conditions to hide pin from /home, /starred or /trash
  • Loading branch information
asmsuechan committed Oct 13, 2017
commit f3370242bfa41eb69cdb2afd901964c857ed035d
4 changes: 2 additions & 2 deletions browser/components/NoteItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => (
<div styleName={isActive
? 'item--active'
: 'item'
Expand All @@ -72,7 +72,7 @@ const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleNoteCont
{note.isStarred
? <i styleName='item-star' className='fa fa-star' /> : ''
}
{note.isPinned
{note.isPinned && !pathname.match(/\/home|\/starred|\/trash/)
? <i styleName='item-pin' className='fa fa-map-pin' /> : ''
}
{note.type === 'MARKDOWN_NOTE'
Expand Down
13 changes: 11 additions & 2 deletions browser/main/NoteList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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}
/>
)
}
Expand Down