From 91f24d96b98752e541a458efb0c34e4a0c51a746 Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Sun, 19 Mar 2017 00:41:55 -0700 Subject: [PATCH] Fix a bug which cannot read a property when moves to other folder on locking --- browser/components/MarkdownEditor.js | 8 ++++---- browser/main/Detail/MarkdownNoteDetail.js | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/browser/components/MarkdownEditor.js b/browser/components/MarkdownEditor.js index 3dd6d15c..9bb50a87 100644 --- a/browser/components/MarkdownEditor.js +++ b/browser/components/MarkdownEditor.js @@ -82,7 +82,7 @@ class MarkdownEditor extends React.Component { this.refs.code.blur() this.refs.preview.focus() } - eventEmitter.emit('topbar:togglelockbutton') + eventEmitter.emit('topbar:togglelockbutton', this.state.status) }) } } @@ -99,7 +99,7 @@ class MarkdownEditor extends React.Component { this.refs.preview.focus() this.refs.preview.scrollTo(cursorPosition.line) }) - eventEmitter.emit('topbar:togglelockbutton') + eventEmitter.emit('topbar:togglelockbutton', this.state.status) } } @@ -115,7 +115,7 @@ class MarkdownEditor extends React.Component { }, () => { this.refs.code.focus() }) - eventEmitter.emit('topbar:togglelockbutton') + eventEmitter.emit('topbar:togglelockbutton', this.state.status) } } @@ -152,7 +152,7 @@ class MarkdownEditor extends React.Component { } else { this.refs.code.focus() } - eventEmitter.emit('topbar:togglelockbutton') + eventEmitter.emit('topbar:togglelockbutton', this.state.status) } reload () { diff --git a/browser/main/Detail/MarkdownNoteDetail.js b/browser/main/Detail/MarkdownNoteDetail.js index 520c0b90..b475d71e 100644 --- a/browser/main/Detail/MarkdownNoteDetail.js +++ b/browser/main/Detail/MarkdownNoteDetail.js @@ -230,8 +230,9 @@ class MarkdownNoteDetail extends React.Component { if (e.keyCode === 27) this.handleDeleteCancelButtonClick(e) } - handleToggleLockButton () { - if (this.props.config.editor.switchPreview === 'BLUR' && this.refs.content.state.status === 'CODE') { + handleToggleLockButton (event, noteStatus) { + // first argument event is not used + if (this.props.config.editor.switchPreview === 'BLUR' && noteStatus === 'CODE') { this.setState({isLockButtonShown: true}) } else { this.setState({isLockButtonShown: false})