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

better formatting

This commit is contained in:
Razvan Moraru
2017-03-23 21:01:49 +01:00
parent 966ba06bc4
commit 6540d2670c

View File

@@ -250,19 +250,13 @@ class SnippetNoteDetail extends React.Component {
} }
deleteSnippetByIndex (index) { deleteSnippetByIndex (index) {
this.setState(() => { const snippets = this.state.note.snippets.slice()
const snippets = this.state.note.snippets.slice() snippets.splice(index, 1)
snippets.splice(index, 1) const note = Object.assign({}, this.state.note, {snippets})
const note = Object.assign({}, this.state.note, {snippets}) const snippetIndex = this.state.snippetIndex >= snippets.length
const snippetIndex = this.state.snippetIndex >= snippets.length ? snippets.length - 1
? snippets.length - 1 : this.state.snippetIndex
: this.state.snippetIndex this.setState({ note, snippetIndex }, () => {
return {
note,
snippetIndex
}
}, () => {
this.save() this.save()
this.refs['code-' + this.state.snippetIndex].reload() this.refs['code-' + this.state.snippetIndex].reload()
}) })