From d6f651568b704dab7890fda68495eb2d12e4a0ee Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 22 Nov 2021 15:04:20 -0500 Subject: [PATCH] A few fixes. --- src/shared/components/home/signup.tsx | 2 +- src/shared/components/person/profile.tsx | 2 +- src/shared/components/post/post.tsx | 4 ++-- src/shared/components/search.tsx | 12 ++++++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/shared/components/home/signup.tsx b/src/shared/components/home/signup.tsx index 1bc3472..ebccac9 100644 --- a/src/shared/components/home/signup.tsx +++ b/src/shared/components/home/signup.tsx @@ -426,7 +426,7 @@ export class Signup extends Component { this.state = this.emptyState; this.state.registerForm.captcha_answer = undefined; // Refetch another captcha - WebSocketService.Instance.send(wsClient.getCaptcha()); + // WebSocketService.Instance.send(wsClient.getCaptcha()); this.setState(this.state); return; } else { diff --git a/src/shared/components/person/profile.tsx b/src/shared/components/person/profile.tsx index 3f4f300..c12038f 100644 --- a/src/shared/components/person/profile.tsx +++ b/src/shared/components/person/profile.tsx @@ -606,7 +606,7 @@ export class Profile extends Component { if ( UserService.Instance.myUserInfo && data.comment_view.creator.id == - UserService.Instance.myUserInfo.local_user_view.person.id + UserService.Instance.myUserInfo?.local_user_view.person.id ) { toast(i18n.t("reply_sent")); } diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index f68d77a..4c7f502 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -269,7 +269,7 @@ export class Post extends Component { } isBottom(el: Element) { - return el.getBoundingClientRect().bottom <= window.innerHeight; + return el?.getBoundingClientRect().bottom <= window.innerHeight; } /** @@ -277,7 +277,7 @@ export class Post extends Component { */ trackCommentsBoxScrolling = () => { const wrappedElement = document.getElementsByClassName("comments")[0]; - if (this.isBottom(wrappedElement)) { + if (wrappedElement && this.isBottom(wrappedElement)) { this.state.maxCommentsShown += commentsShownInterval; this.setState(this.state); } diff --git a/src/shared/components/search.tsx b/src/shared/components/search.tsx index 5257489..596b7e5 100644 --- a/src/shared/components/search.tsx +++ b/src/shared/components/search.tsx @@ -809,10 +809,14 @@ export class Search extends Component { this.creatorChoices.passedElement.element.addEventListener( "search", debounce(async (e: any) => { - let creators = (await fetchUsers(e.detail.value)).users; - let choices = creators.map(pvs => personToChoice(pvs)); - choices.unshift({ value: "0", label: i18n.t("all") }); - this.creatorChoices.setChoices(choices, "value", "label", true); + try { + let creators = (await fetchUsers(e.detail.value)).users; + let choices = creators.map(pvs => personToChoice(pvs)); + choices.unshift({ value: "0", label: i18n.t("all") }); + this.creatorChoices.setChoices(choices, "value", "label", true); + } catch (err) { + console.log(err); + } }, 400), false ); -- 2.44.1