From: Dessalines Date: Tue, 16 Nov 2021 15:37:40 +0000 (-0500) Subject: Fixing unload (#487) X-Git-Url: http://these/git/%22https:/lemmy.ml/u/Liwott/sneer-club-logo.svg?a=commitdiff_plain;h=83b8bcd5e14efc57c8156ec6b981b5b302ed27d8;p=lemmy-ui.git Fixing unload (#487) --- diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index 1213c5a..499330c 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -88,6 +88,7 @@ interface PostState { export class Post extends Component { private subscription: Subscription; private isoData = setIsoData(this.context); + private commentScrollDebounced: () => void; private emptyState: PostState = { postRes: null, postId: getIdFromProps(this.props), @@ -178,7 +179,8 @@ export class Post extends Component { componentWillUnmount() { this.subscription.unsubscribe(); - document.removeEventListener("scroll", this.trackCommentsBoxScrolling); + document.removeEventListener("scroll", this.commentScrollDebounced); + window.isoData.path = undefined; saveScrollPosition(this.context); } @@ -189,10 +191,8 @@ export class Post extends Component { ); 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) {