Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Change x mark by shouldComponentUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdh committed Jul 27, 2016
1 parent f7fa659 commit 0359c3a
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,26 +163,13 @@ class GeneralTab extends ImmutableComponent {
}
}

class SearchSelectEntry extends React.Component {
constructor (props) {
super(props)
this.state = {
select: props.name === getSetting(settings.DEFAULT_SEARCH_ENGINE)
}

ipc.on(messages.SETTINGS_UPDATED, (e, settings) => {
const settingsMap = Immutable.fromJS(settings || {})
if (this.props.name === settingsMap.get('search.default-search-engine')) {
this.setState({select: true})
} else {
this.setState({select: false})
}
})
class SearchSelectEntry extends ImmutableComponent {
shouldComponentUpdate (nextProps, nextState) {
return this.props.settings.get('search.default-search-engine') !== nextProps.settings.get('search.default-search-engine')
}

render () {
return <div>
{this.state.select ? 'x' : ''}
{this.props.settings.get('search.default-search-engine') === this.props.name ? 'x' : ''}
</div>
}
}
Expand Down Expand Up @@ -224,7 +211,7 @@ class SearchTab extends ImmutableComponent {
paddingLeft: '5px',
verticalAlign: 'middle'
}
array.push([<SearchSelectEntry name={entry.name} />,
array.push([<SearchSelectEntry name={entry.name} settings={this.props.settings} />,
<SearchEntry name={entry.name} iconStyle={iconStyle} textStyle={textStyle}
onChangeSetting={this.props.onChangeSetting} />,
<SearchShortcutEntry shortcut={entry.shortcut} textStyle={textStyle} />])
Expand Down

0 comments on commit 0359c3a

Please sign in to comment.