Fix refreshing behavior on new input in WunderBar

Before, <WunderBar /> would compare the address inside it to the page
address passed in by <Header /> to determine if there was a page change.
This would cause user input to be replaced with "Home" when typing a
search, since during a search the page address is always "Home," not
the query.

Now it simply checks if the page being viewed has changed.
This commit is contained in:
Alex Liebowitz 2017-04-30 04:07:35 -04:00 committed by Jeremy Kauffman
parent e42252507b
commit a82ee8a2d5

View file

@ -34,7 +34,7 @@ var Header = React.createClass({
<Link href="?discover" button="alt button--flat" icon="icon-home" />
</div>
<div className="header__item header__item--wunderbar">
<WunderBar address={this.props.address} icon={this.props.wunderBarIcon} onSearch={this.props.onSearch} />
<WunderBar address={this.props.address} icon={this.props.wunderBarIcon} onSearch={this.props.onSearch} viewingPage={this.props.viewingPage} />
</div>
<div className="header__item">
<Link href="?wallet" button="text" icon="icon-bank" label={lbry.formatCredits(this.state.balance, 1)} ></Link>
@ -86,7 +86,7 @@ let WunderBar = React.createClass({
},
componentWillReceiveProps(nextProps) {
if (nextProps.address !== this.state.address || nextProps.icon !== this.state.icon) {
if (nextProps.viewingPage !== this.props.viewingPage) {
this.setState({ address: nextProps.address, icon: nextProps.icon });
}
},