mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
Remove a dialogbox from onTrashButtonClick
This commit is contained in:
@@ -179,40 +179,37 @@ 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: 'This work cannot be undone.',
|
||||||
detail: popupMessage,
|
buttons: ['Confirm', 'Cancel']
|
||||||
buttons: ['Confirm', 'Cancel']
|
})
|
||||||
})
|
if (dialogueButtonIndex === 1) return
|
||||||
if (dialogueButtonIndex === 0) {
|
let { note, dispatch } = this.props
|
||||||
if (!isTrashed) {
|
dataApi
|
||||||
note.isTrashed = true
|
.deleteNote(note.storage, note.key)
|
||||||
|
.then((data) => {
|
||||||
this.setState({
|
let dispatchHandler = () => {
|
||||||
note
|
dispatch({
|
||||||
}, () => {
|
type: 'DELETE_NOTE',
|
||||||
this.save()
|
storageKey: data.storageKey,
|
||||||
|
noteKey: data.noteKey
|
||||||
|
})
|
||||||
|
}
|
||||||
|
ee.once('list:moved', dispatchHandler)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let { note, dispatch } = this.props
|
note.isTrashed = true
|
||||||
dataApi
|
|
||||||
.deleteNote(note.storage, note.key)
|
this.setState({
|
||||||
.then((data) => {
|
note
|
||||||
let dispatchHandler = () => {
|
}, () => {
|
||||||
dispatch({
|
this.save()
|
||||||
type: 'DELETE_NOTE',
|
})
|
||||||
storageKey: data.storageKey,
|
|
||||||
noteKey: data.noteKey
|
|
||||||
})
|
|
||||||
}
|
|
||||||
ee.once('list:moved', dispatchHandler)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
ee.emit('list:next')
|
|
||||||
}
|
}
|
||||||
|
ee.emit('list:next')
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUndoButtonClick (e) {
|
handleUndoButtonClick (e) {
|
||||||
|
|||||||
@@ -173,40 +173,37 @@ 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: 'This work cannot be undone.',
|
||||||
detail: popupMessage,
|
buttons: ['Confirm', 'Cancel']
|
||||||
buttons: ['Confirm', 'Cancel']
|
})
|
||||||
})
|
if (dialogueButtonIndex === 1) return
|
||||||
if (dialogueButtonIndex === 0) {
|
let { note, dispatch } = this.props
|
||||||
if (!isTrashed) {
|
dataApi
|
||||||
note.isTrashed = true
|
.deleteNote(note.storage, note.key)
|
||||||
|
.then((data) => {
|
||||||
this.setState({
|
let dispatchHandler = () => {
|
||||||
note
|
dispatch({
|
||||||
}, () => {
|
type: 'DELETE_NOTE',
|
||||||
this.save()
|
storageKey: data.storageKey,
|
||||||
|
noteKey: data.noteKey
|
||||||
|
})
|
||||||
|
}
|
||||||
|
ee.once('list:moved', dispatchHandler)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let { note, dispatch } = this.props
|
note.isTrashed = true
|
||||||
dataApi
|
|
||||||
.deleteNote(note.storage, note.key)
|
this.setState({
|
||||||
.then((data) => {
|
note
|
||||||
let dispatchHandler = () => {
|
}, () => {
|
||||||
dispatch({
|
this.save()
|
||||||
type: 'DELETE_NOTE',
|
})
|
||||||
storageKey: data.storageKey,
|
|
||||||
noteKey: data.noteKey
|
|
||||||
})
|
|
||||||
}
|
|
||||||
ee.once('list:moved', dispatchHandler)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
ee.emit('list:next')
|
|
||||||
}
|
}
|
||||||
|
ee.emit('list:next')
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUndoButtonClick (e) {
|
handleUndoButtonClick (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user