1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Resolve conflicts

This commit is contained in:
asmsuechan
2017-10-13 13:34:43 +09:00
parent c33da0cf8e
commit 725c6a7ba9
2 changed files with 56 additions and 65 deletions

View File

@@ -44,10 +44,8 @@ const TagElementList = (tags) => {
* @param {Function} handleNoteContextMenu * @param {Function} handleNoteContextMenu
* @param {Function} handleDragStart * @param {Function} handleDragStart
* @param {string} dateDisplay * @param {string} dateDisplay
* @param {Function} handleNoteContextMenu
* @param {string} pathname
*/ */
const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleDragStart, handleNoteContextMenu, pathname }) => ( const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleNoteContextMenu, handleDragStart, pathname }) => (
<div styleName={isActive <div styleName={isActive
? 'item--active' ? 'item--active'
: 'item' : 'item'

View File

@@ -366,7 +366,20 @@ class NoteList extends React.Component {
handleNoteContextMenu (e, uniqueKey) { handleNoteContextMenu (e, uniqueKey) {
this.handleNoteClick(e, uniqueKey) this.handleNoteClick(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() let menu = new Menu()
if (!location.pathname.match(/\/home|\/starred|\/trash/)) {
menu.append(new MenuItem({
label: label,
click: (e) => this.handlePinToTop(e, uniqueKey)
}))
}
menu.append(new MenuItem({ menu.append(new MenuItem({
label: 'Delete Note', label: 'Delete Note',
click: () => ee.emit('detail:delete') click: () => ee.emit('detail:delete')
@@ -374,6 +387,47 @@ class NoteList extends React.Component {
menu.popup() menu.popup()
} }
handlePinToTop (e, uniqueKey) {
const { data, location } = this.props
let splitted = location.pathname.split('/')
const storageKey = splitted[2]
const folderKey = splitted[4]
const currentStorage = data.storageMap.get(storageKey)
const currentFolder = _.find(currentStorage.folders, {key: folderKey})
dataApi
.updateFolder(storageKey, folderKey, {
color: currentFolder.color,
name: currentFolder.name,
pinnedNote: uniqueKey.split('-').pop()
})
.then((data) => {
store.dispatch({
type: 'UPDATE_FOLDER',
storage: data.storage
})
this.setState({
status: 'IDLE'
})
})
let targetIndex = _.findIndex(this.notes, (note) => {
return note != null && note.storage + '-' + note.key === uniqueKey
})
let note = this.notes[targetIndex]
note.isPinned = !note.isPinned
dataApi
.updateNote(note.storage, note.key, note)
.then((note) => {
store.dispatch({
type: 'UPDATE_NOTE',
note: note
})
})
}
importFromFile () { importFromFile () {
const { dispatch, location } = this.props const { dispatch, location } = this.props
@@ -433,66 +487,6 @@ 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)
}))
if (!location.pathname.match(/\/home|\/starred|\/trash/)) {
menu.popup()
}
}
handlePinToTop (e, uniqueKey) {
const { data, location } = this.props
let splitted = location.pathname.split('/')
const storageKey = splitted[2]
const folderKey = splitted[4]
const currentStorage = data.storageMap.get(storageKey)
const currentFolder = _.find(currentStorage.folders, {key: folderKey})
dataApi
.updateFolder(storageKey, folderKey, {
color: currentFolder.color,
name: currentFolder.name,
pinnedNote: uniqueKey.split('-').pop()
})
.then((data) => {
store.dispatch({
type: 'UPDATE_FOLDER',
storage: data.storage
})
this.setState({
status: 'IDLE'
})
})
let targetIndex = _.findIndex(this.notes, (note) => {
return note != null && note.storage + '-' + note.key === uniqueKey
})
let note = this.notes[targetIndex]
note.isPinned = !note.isPinned
dataApi
.updateNote(note.storage, note.key, note)
.then((note) => {
store.dispatch({
type: 'UPDATE_NOTE',
note: note
})
})
}
render () { render () {
let { location, notes, config, dispatch } = this.props let { location, notes, config, dispatch } = this.props
let sortFunc = config.sortBy === 'CREATED_AT' let sortFunc = config.sortBy === 'CREATED_AT'
@@ -530,7 +524,6 @@ class NoteList extends React.Component {
key={key} key={key}
handleNoteContextMenu={this.handleNoteContextMenu.bind(this)} handleNoteContextMenu={this.handleNoteContextMenu.bind(this)}
handleNoteClick={this.handleNoteClick.bind(this)} handleNoteClick={this.handleNoteClick.bind(this)}
handleNoteContextMenu={this.handleNoteContextMenu.bind(this)}
handleDragStart={this.handleDragStart.bind(this)} handleDragStart={this.handleDragStart.bind(this)}
pathname={location.pathname} pathname={location.pathname}
/> />
@@ -608,4 +601,4 @@ NoteList.propTypes = {
}) })
} }
export default CSSModules(NoteList, styles)