Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Remove a dialogbox from onTrashButtonClick
  • Loading branch information
asmsuechan committed Jul 15, 2017
commit 804ac1aa96ae5974bf5aacc913d8ef3fced21c02
61 changes: 29 additions & 32 deletions browser/main/Detail/MarkdownNoteDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,40 +179,37 @@ class MarkdownNoteDetail extends React.Component {
let { note } = this.state
const { isTrashed } = note

const popupMessage = isTrashed ? 'This work cannot be undone.' : 'Throw it into trashbox.'

let dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), {
type: 'warning',
message: 'Delete a note',
detail: popupMessage,
buttons: ['Confirm', 'Cancel']
})
if (dialogueButtonIndex === 0) {
if (!isTrashed) {
note.isTrashed = true

this.setState({
note
}, () => {
this.save()
if (isTrashed) {
let dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), {
type: 'warning',
message: 'Delete a note',
detail: 'This work cannot be undone.',
buttons: ['Confirm', 'Cancel']
})
if (dialogueButtonIndex === 1) return
let { note, dispatch } = this.props
dataApi
.deleteNote(note.storage, note.key)
.then((data) => {
let dispatchHandler = () => {
dispatch({
type: 'DELETE_NOTE',
storageKey: data.storageKey,
noteKey: data.noteKey
})
}
ee.once('list:moved', dispatchHandler)
})
} else {
let { note, dispatch } = this.props
dataApi
.deleteNote(note.storage, note.key)
.then((data) => {
let dispatchHandler = () => {
dispatch({
type: 'DELETE_NOTE',
storageKey: data.storageKey,
noteKey: data.noteKey
})
}
ee.once('list:moved', dispatchHandler)
})
}
ee.emit('list:next')
} else {
note.isTrashed = true

this.setState({
note
}, () => {
this.save()
})
}
ee.emit('list:next')
}

handleUndoButtonClick (e) {
Expand Down
61 changes: 29 additions & 32 deletions browser/main/Detail/SnippetNoteDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,40 +173,37 @@ class SnippetNoteDetail extends React.Component {
let { note } = this.state
const { isTrashed } = note

const popupMessage = isTrashed ? 'This work cannot be undone.' : 'Throw it into trashbox.'

let dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), {
type: 'warning',
message: 'Delete a note',
detail: popupMessage,
buttons: ['Confirm', 'Cancel']
})
if (dialogueButtonIndex === 0) {
if (!isTrashed) {
note.isTrashed = true

this.setState({
note
}, () => {
this.save()
if (isTrashed) {
let dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), {
type: 'warning',
message: 'Delete a note',
detail: 'This work cannot be undone.',
buttons: ['Confirm', 'Cancel']
})
if (dialogueButtonIndex === 1) return
let { note, dispatch } = this.props
dataApi
.deleteNote(note.storage, note.key)
.then((data) => {
let dispatchHandler = () => {
dispatch({
type: 'DELETE_NOTE',
storageKey: data.storageKey,
noteKey: data.noteKey
})
}
ee.once('list:moved', dispatchHandler)
})
} else {
let { note, dispatch } = this.props
dataApi
.deleteNote(note.storage, note.key)
.then((data) => {
let dispatchHandler = () => {
dispatch({
type: 'DELETE_NOTE',
storageKey: data.storageKey,
noteKey: data.noteKey
})
}
ee.once('list:moved', dispatchHandler)
})
}
ee.emit('list:next')
} else {
note.isTrashed = true

this.setState({
note
}, () => {
this.save()
})
}
ee.emit('list:next')
}

handleUndoButtonClick (e) {
Expand Down