Skip to content

Commit

Permalink
Fixing unload (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines authored Nov 16, 2021
1 parent 387f474 commit 83b8bcd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/shared/components/post/post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ interface PostState {
export class Post extends Component<any, PostState> {
private subscription: Subscription;
private isoData = setIsoData(this.context);
private commentScrollDebounced: () => void;
private emptyState: PostState = {
postRes: null,
postId: getIdFromProps(this.props),
Expand Down Expand Up @@ -178,7 +179,8 @@ export class Post extends Component<any, PostState> {

componentWillUnmount() {
this.subscription.unsubscribe();
document.removeEventListener("scroll", this.trackCommentsBoxScrolling);
document.removeEventListener("scroll", this.commentScrollDebounced);

window.isoData.path = undefined;
saveScrollPosition(this.context);
}
Expand All @@ -189,10 +191,8 @@ export class Post extends Component<any, PostState> {
);
autosize(document.querySelectorAll("textarea"));

document.addEventListener(
"scroll",
debounce(this.trackCommentsBoxScrolling, 100)
);
this.commentScrollDebounced = debounce(this.trackCommentsBoxScrolling, 100);
document.addEventListener("scroll", this.commentScrollDebounced);
}

componentDidUpdate(_lastProps: any, lastState: PostState) {
Expand Down

0 comments on commit 83b8bcd

Please sign in to comment.