1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 02:06:29 +00:00

fix newNoteModal create note twice after double click quickly

This commit is contained in:
linxiuda
2019-02-10 13:03:55 +08:00
committed by Junyoung Choi
parent 1675e04f90
commit 5e134f990e

View File

@@ -8,7 +8,7 @@ import { createMarkdownNote, createSnippetNote } from 'browser/lib/newNote'
class NewNoteModal extends React.Component { class NewNoteModal extends React.Component {
constructor (props) { constructor (props) {
super(props) super(props)
this.lock = false
this.state = {} this.state = {}
} }
@@ -22,10 +22,13 @@ class NewNoteModal extends React.Component {
handleMarkdownNoteButtonClick (e) { handleMarkdownNoteButtonClick (e) {
const { storage, folder, dispatch, location, params, config } = this.props const { storage, folder, dispatch, location, params, config } = this.props
if (!this.lock) {
this.lock = true
createMarkdownNote(storage, folder, dispatch, location, params, config).then(() => { createMarkdownNote(storage, folder, dispatch, location, params, config).then(() => {
setTimeout(this.props.close, 200) setTimeout(this.props.close, 200)
}) })
} }
}
handleMarkdownNoteButtonKeyDown (e) { handleMarkdownNoteButtonKeyDown (e) {
if (e.keyCode === 9) { if (e.keyCode === 9) {
@@ -36,10 +39,13 @@ class NewNoteModal extends React.Component {
handleSnippetNoteButtonClick (e) { handleSnippetNoteButtonClick (e) {
const { storage, folder, dispatch, location, params, config } = this.props const { storage, folder, dispatch, location, params, config } = this.props
if (!this.lock) {
this.lock = true
createSnippetNote(storage, folder, dispatch, location, params, config).then(() => { createSnippetNote(storage, folder, dispatch, location, params, config).then(() => {
setTimeout(this.props.close, 200) setTimeout(this.props.close, 200)
}) })
} }
}
handleSnippetNoteButtonKeyDown (e) { handleSnippetNoteButtonKeyDown (e) {
if (e.keyCode === 9) { if (e.keyCode === 9) {