Upgrading views

This commit is contained in:
James Barnsley
2020-03-12 08:31:32 +13:00
parent 3e56a3f873
commit 315dd92984
3 changed files with 59 additions and 31 deletions

View File

@ -18,14 +18,25 @@ class DiscoverCategory extends React.Component {
this.setWindowTitle();
}
componentWillReceiveProps(nextProps) {
if (nextProps.match.params.id != this.props.match.params.id) {
this.loadCategory();
}
componentDidUpdate = ({
match: {
params: {
id: prevId,
},
},
category: prevCategory,
}) => {
const {
match: {
params: {
id,
},
},
category,
} = this.props;
if (!this.props.category && nextProps.category) {
this.setWindowTitle(nextProps.category);
}
if (prevId !== id) this.loadCategory();
if (!prevCategory && category) this.setWindowTitle(category);
}
setWindowTitle(category = this.props.category) {

View File

@ -158,11 +158,21 @@ class Discover extends React.Component {
}
}
componentWillReceiveProps(newProps, newState) {
// New seeds via URL
if (newProps.match.params.seeds != this.props.match.params.seeds) {
this.handleURLSeeds(newProps.match.params.seeds);
}
componentDiUpdate = ({
match: {
params: {
seeds: prevSeeds,
},
},
}) => {
const {
match: {
params: {
seeds,
},
},
} = this.props;
if (prevSeeds !== seeds) this.handleURLSeeds(seeds);
}
handleContextMenu(e) {