From b0a711a4ac235ae8db3cb67202e791eb874ff5e8 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Fri, 10 May 2024 11:01:34 -0400 Subject: [PATCH 1/2] Fix bug where UI breaks trying to send a DM (#2452) --- .../private_message/private-message-form.tsx | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/shared/components/private_message/private-message-form.tsx b/src/shared/components/private_message/private-message-form.tsx index 40a75114..cf2fed64 100644 --- a/src/shared/components/private_message/private-message-form.tsx +++ b/src/shared/components/private_message/private-message-form.tsx @@ -47,6 +47,8 @@ export class PrivateMessageForm extends Component< super(props, context); this.handleContentChange = this.handleContentChange.bind(this); + this.handlePrivateMessageSubmit = + this.handlePrivateMessageSubmit.bind(this); } componentWillReceiveProps( @@ -118,9 +120,7 @@ export class PrivateMessageForm extends Component<
{ - this.handlePrivateMessageSubmit(this, event); - }} + onSubmit={this.handlePrivateMessageSubmit} initialContent={this.state.content} onContentChange={this.handleContentChange} allLanguages={[]} @@ -140,20 +140,19 @@ export class PrivateMessageForm extends Component< ); } - handlePrivateMessageSubmit(i: PrivateMessageForm, event: any) { - event.preventDefault(); - i.setState({ loading: true, submitted: true }); - const pm = i.props.privateMessageView; - const content = i.state.content ?? ""; + handlePrivateMessageSubmit() { + this.setState({ loading: true, submitted: true }); + const pm = this.props.privateMessageView; + const content = this.state.content ?? ""; if (pm) { - i.props.onEdit?.({ + this.props.onEdit?.({ private_message_id: pm.private_message.id, content, }); } else { - i.props.onCreate?.({ + this.props.onCreate?.({ content, - recipient_id: i.props.recipient.id, + recipient_id: this.props.recipient.id, }); } } From 17097ecd34fd65a900825ec488f47a9ccdae839f Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Fri, 10 May 2024 11:04:31 -0400 Subject: [PATCH 2/2] Fix bug where newly created communities cannot be edited until refresh (#2451) * Fix bug where newly created communities cannot be edited until refresh * Fix bug with slightly less crappy kludge than before --- package.json | 2 +- src/shared/components/community/create-community.tsx | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3e8976a9..ad550bae 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,7 @@ "sortpack" ] }, - "packageManager": "pnpm@9.0.6+sha256.0624e30eff866cdeb363b15061bdb7fd9425b17bc1bb42c22f5f4efdea21f6b3", + "packageManager": "pnpm@9.1.0+sha512.67f5879916a9293e5cf059c23853d571beaf4f753c707f40cb22bed5fb1578c6aad3b6c4107ccb3ba0b35be003eb621a16471ac836c87beb53f9d54bb4612724", "engineStrict": true, "importSort": { ".js, .jsx, .ts, .tsx": { diff --git a/src/shared/components/community/create-community.tsx b/src/shared/components/community/create-community.tsx index cf9345cb..e3377bcc 100644 --- a/src/shared/components/community/create-community.tsx +++ b/src/shared/components/community/create-community.tsx @@ -4,7 +4,7 @@ import { CreateCommunity as CreateCommunityI, GetSiteResponse, } from "lemmy-js-client"; -import { HttpService, I18NextService } from "../../services"; +import { HttpService, I18NextService, UserService } from "../../services"; import { HtmlTags } from "../common/html-tags"; import { CommunityForm } from "./community-form"; import { simpleScrollMixin } from "../mixins/scroll-mixin"; @@ -68,6 +68,11 @@ export class CreateCommunity extends Component< const res = await HttpService.client.createCommunity(form); if (res.state === "success") { + const myUser = UserService.Instance.myUserInfo!; + UserService.Instance.myUserInfo?.moderates.push({ + community: res.data.community_view.community, + moderator: myUser.local_user_view.person, + }); const name = res.data.community_view.community.name; this.props.history.replace(`/c/${name}`); } else {