Skip to content

Commit f4ca86b

Browse files
author
Mug
committed
Fixed reload-follow button bug
1 parent 9c77d5e commit f4ca86b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Manga.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export class FollowButton extends React.Component {
399399
const { user, setUser } = this.context;
400400

401401
//TODO: This doesn't always fire?
402-
if (user != null) {
402+
if (user != null && this.props.id != null) {
403403
API.followsManga(this.props.id).then((r) => {
404404
if (this.state.isFollowed != r) {
405405
this.setState({
@@ -409,6 +409,11 @@ export class FollowButton extends React.Component {
409409
})
410410
}
411411
}
412+
componentDidUpdate(prevProps) {
413+
if (this.props.id != prevProps.id) {
414+
this.componentDidMount();
415+
}
416+
}
412417

413418
render() {
414419
const { user, setUser } = this.context;
@@ -725,7 +730,7 @@ export class MangaDisplay extends React.Component {
725730
<div className="col-lg-3 col-xl-2 strong">Actions:</div>
726731
<div className="col-lg-9 col-xl-10">
727732
{/*display_upload_button($templateVar["user"])*/}
728-
<FollowButton id={manga != null && manga.getId()}/>
733+
<FollowButton id={manga != null ? manga.getId() : null}/>
729734
{/*display_manga_rating_button($templateVar["user"]->user_id, $templateVar["manga"]->get_user_rating($templateVar["user"]->user_id), $templateVar["manga"]->manga_id)*/}
730735
{/*display_edit_manga($templateVar["user"], $templateVar["manga"])*/}
731736
{/*<?php if (validate_level($templateVar["user"], "member")) :

0 commit comments

Comments
 (0)