Skip to content

Commit a9bad53

Browse files
authored
Merge pull request #2438 from jacobherrington/fix-type-error-on-snippets
Fix TypeError thrown on the Snippets page
2 parents eee3403 + b29c0fe commit a9bad53

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

browser/main/modals/PreferencesModal/SnippetTab.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ class SnippetTab extends React.Component {
4141

4242
handleSnippetSelect (snippet) {
4343
const { currentSnippet } = this.state
44-
if (currentSnippet === null || currentSnippet.id !== snippet.id) {
45-
dataApi.fetchSnippet(snippet.id).then(changedSnippet => {
46-
// notify the snippet editor to load the content of the new snippet
47-
this.snippetEditor.onSnippetChanged(changedSnippet)
48-
this.setState({currentSnippet: changedSnippet})
49-
})
44+
if (snippet !== null) {
45+
if (currentSnippet === null || currentSnippet.id !== snippet.id) {
46+
dataApi.fetchSnippet(snippet.id).then(changedSnippet => {
47+
// notify the snippet editor to load the content of the new snippet
48+
this.snippetEditor.onSnippetChanged(changedSnippet)
49+
this.setState({currentSnippet: changedSnippet})
50+
})
51+
}
5052
}
5153
}
5254

0 commit comments

Comments
 (0)