1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 01:36:22 +00:00

Add conditions to hide pin from /home, /starred or /trash

This commit is contained in:
asmsuechan
2017-10-13 13:12:41 +09:00
parent 0e312ba929
commit f3370242bf
2 changed files with 13 additions and 4 deletions

View File

@@ -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'
@@ -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'

View File

@@ -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}
/>
)
}