1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 10:16:26 +00:00

Remove a dialogbox from onTrashButtonClick

This commit is contained in:
asmsuechan
2017-07-15 12:45:03 +09:00
parent 8d71b28afa
commit 804ac1aa96
2 changed files with 58 additions and 64 deletions

View File

@@ -179,24 +179,14 @@ class MarkdownNoteDetail extends React.Component {
let { note } = this.state let { note } = this.state
const { isTrashed } = note const { isTrashed } = note
const popupMessage = isTrashed ? 'This work cannot be undone.' : 'Throw it into trashbox.' if (isTrashed) {
let dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), { let dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), {
type: 'warning', type: 'warning',
message: 'Delete a note', message: 'Delete a note',
detail: popupMessage, detail: 'This work cannot be undone.',
buttons: ['Confirm', 'Cancel'] buttons: ['Confirm', 'Cancel']
}) })
if (dialogueButtonIndex === 0) { if (dialogueButtonIndex === 1) return
if (!isTrashed) {
note.isTrashed = true
this.setState({
note
}, () => {
this.save()
})
} else {
let { note, dispatch } = this.props let { note, dispatch } = this.props
dataApi dataApi
.deleteNote(note.storage, note.key) .deleteNote(note.storage, note.key)
@@ -210,10 +200,17 @@ class MarkdownNoteDetail extends React.Component {
} }
ee.once('list:moved', dispatchHandler) ee.once('list:moved', dispatchHandler)
}) })
} else {
note.isTrashed = true
this.setState({
note
}, () => {
this.save()
})
} }
ee.emit('list:next') ee.emit('list:next')
} }
}
handleUndoButtonClick (e) { handleUndoButtonClick (e) {
let { note } = this.state let { note } = this.state

View File

@@ -173,24 +173,14 @@ class SnippetNoteDetail extends React.Component {
let { note } = this.state let { note } = this.state
const { isTrashed } = note const { isTrashed } = note
const popupMessage = isTrashed ? 'This work cannot be undone.' : 'Throw it into trashbox.' if (isTrashed) {
let dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), { let dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), {
type: 'warning', type: 'warning',
message: 'Delete a note', message: 'Delete a note',
detail: popupMessage, detail: 'This work cannot be undone.',
buttons: ['Confirm', 'Cancel'] buttons: ['Confirm', 'Cancel']
}) })
if (dialogueButtonIndex === 0) { if (dialogueButtonIndex === 1) return
if (!isTrashed) {
note.isTrashed = true
this.setState({
note
}, () => {
this.save()
})
} else {
let { note, dispatch } = this.props let { note, dispatch } = this.props
dataApi dataApi
.deleteNote(note.storage, note.key) .deleteNote(note.storage, note.key)
@@ -204,10 +194,17 @@ class SnippetNoteDetail extends React.Component {
} }
ee.once('list:moved', dispatchHandler) ee.once('list:moved', dispatchHandler)
}) })
} else {
note.isTrashed = true
this.setState({
note
}, () => {
this.save()
})
} }
ee.emit('list:next') ee.emit('list:next')
} }
}
handleUndoButtonClick (e) { handleUndoButtonClick (e) {
let { note } = this.state let { note } = this.state