Skip to content

Commit

Permalink
fix(dismiss): fix link to detailed Notice being triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
lutangar committed Jul 8, 2019
1 parent a3d1964 commit fd0d913
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/components/organisms/Notice/Notice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,10 @@ export default class Notice extends PureComponent<Props, CountDownState> {
const { intervalID } = this.state;
if (intervalID) {
window.clearInterval(intervalID);
this.setState({ intervalID: null });
}
};

onUndismiss = () => {
this.stopCountdown();
};

componentWillUnmount(): void {
this.stopCountdown();
}
Expand All @@ -130,7 +127,7 @@ export default class Notice extends PureComponent<Props, CountDownState> {
<Container style={style}>
{!dismissed && !disliked && <DeleteButton onClick={this.onDismiss} />}
<Content
to={dismissed ? undefined : `notices/details/${id}`}
to={dismissed || intervalID ? undefined : `notices/details/${id}`}
read={read}
>
{(dismissed || disliked) && intervalID ? (
Expand Down
5 changes: 3 additions & 2 deletions src/components/organisms/NoticeDetails/NoticeDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class NoticeDetails extends PureComponent<NoticeDetailsProps, CountDownState> {
stopCountdown = () => {
if (this.state.intervalID) {
window.clearInterval(this.state.intervalID);
this.setState({ intervalID: null });
}
};

Expand Down Expand Up @@ -93,7 +94,7 @@ class NoticeDetails extends PureComponent<NoticeDetailsProps, CountDownState> {
const { notice: { id }, undislike } = this.props;
undislike(id);
this.stopCountdown();
}
};

handleFollowSource = () => {
const {
Expand Down Expand Up @@ -124,7 +125,7 @@ class NoticeDetails extends PureComponent<NoticeDetailsProps, CountDownState> {
contributor,
source,
ratings: { likes, dislikes },
state: { liked, disliked }
state: { liked, disliked, dismissed }
}
} = this.props;

Expand Down

0 comments on commit fd0d913

Please sign in to comment.