1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

First snippet is selected when open Snippets tab

This commit is contained in:
Sosuke Suzuki
2018-06-27 16:13:42 +09:00
parent 5c60da0f8f
commit c42b5c8806
2 changed files with 7 additions and 4 deletions

View File

@@ -21,7 +21,10 @@ class SnippetList extends React.Component {
} }
reloadSnippetList () { reloadSnippetList () {
dataApi.fetchSnippet().then(snippets => this.setState({snippets})) dataApi.fetchSnippet().then(snippets => {
this.setState({snippets})
this.props.onSnippetSelect(snippets[0])
})
} }
handleSnippetContextMenu (snippet) { handleSnippetContextMenu (snippet) {
@@ -43,7 +46,7 @@ class SnippetList extends React.Component {
} }
handleSnippetClick (snippet) { handleSnippetClick (snippet) {
this.props.onSnippetClick(snippet) this.props.onSnippetSelect(snippet)
} }
createSnippet () { createSnippet () {

View File

@@ -25,7 +25,7 @@ class SnippetTab extends React.Component {
}, 500) }, 500)
} }
handleSnippetClick (snippet) { handleSnippetSelect (snippet) {
const { currentSnippet } = this.state const { currentSnippet } = this.state
if (currentSnippet === null || currentSnippet.id !== snippet.id) { if (currentSnippet === null || currentSnippet.id !== snippet.id) {
dataApi.fetchSnippet(snippet.id).then(changedSnippet => { dataApi.fetchSnippet(snippet.id).then(changedSnippet => {
@@ -66,7 +66,7 @@ class SnippetTab extends React.Component {
<div styleName='root'> <div styleName='root'>
<div styleName='header'>{i18n.__('Snippets')}</div> <div styleName='header'>{i18n.__('Snippets')}</div>
<SnippetList <SnippetList
onSnippetClick={this.handleSnippetClick.bind(this)} onSnippetSelect={this.handleSnippetSelect.bind(this)}
onSnippetDeleted={this.handleDeleteSnippet.bind(this)} /> onSnippetDeleted={this.handleDeleteSnippet.bind(this)} />
<div styleName='snippet-detail' style={{visibility: currentSnippet ? 'visible' : 'hidden'}}> <div styleName='snippet-detail' style={{visibility: currentSnippet ? 'visible' : 'hidden'}}>
<div styleName='group-section'> <div styleName='group-section'>