This commit is contained in:
David Ralph
2021-01-16 22:43:46 +00:00
parent 0a735384df
commit 3ec5a2c199
32 changed files with 530 additions and 182 deletions

View File

@@ -20,18 +20,26 @@ export default class Favourite extends React.PureComponent {
const location = document.getElementById('location').textContent;
localStorage.setItem('favourite', JSON.stringify({ url: url, credit: credit, location: location }));
this.setState({ favourited: <StarIcon onClick={() => this.favourite()} /> });
this.setState({
favourited: <StarIcon onClick={() => this.favourite()} />
});
}
}
componentDidMount() {
if (localStorage.getItem('favourite')) {
this.setState({ favourited: <StarIcon onClick={() => this.favourite()} /> });
this.setState({
favourited: <StarIcon onClick={() => this.favourite()} />
});
}
}
render() {
if (localStorage.getItem('favouriteEnabled') === 'false' || localStorage.getItem('background') === 'false' || localStorage.getItem('customBackgroundColour') || localStorage.getItem('customBackground')) return null;
if (localStorage.getItem('favouriteEnabled') === 'false' || localStorage.getItem('background') === 'false' || localStorage.getItem('customBackgroundColour') || localStorage.getItem('customBackground')) {
return null;
}
return <div className='favourite'>
{this.state.favourited}
</div>