Merge branch 'main' into leap-year-cake-day

This commit is contained in:
SleeplessOne1917 2024-05-10 15:15:19 -04:00 committed by GitHub
commit 0d4a583c9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 13 deletions

View file

@ -141,7 +141,7 @@
"sortpack" "sortpack"
] ]
}, },
"packageManager": "pnpm@9.0.6+sha256.0624e30eff866cdeb363b15061bdb7fd9425b17bc1bb42c22f5f4efdea21f6b3", "packageManager": "pnpm@9.1.0+sha512.67f5879916a9293e5cf059c23853d571beaf4f753c707f40cb22bed5fb1578c6aad3b6c4107ccb3ba0b35be003eb621a16471ac836c87beb53f9d54bb4612724",
"engineStrict": true, "engineStrict": true,
"importSort": { "importSort": {
".js, .jsx, .ts, .tsx": { ".js, .jsx, .ts, .tsx": {

View file

@ -4,7 +4,7 @@ import {
CreateCommunity as CreateCommunityI, CreateCommunity as CreateCommunityI,
GetSiteResponse, GetSiteResponse,
} from "lemmy-js-client"; } from "lemmy-js-client";
import { HttpService, I18NextService } from "../../services"; import { HttpService, I18NextService, UserService } from "../../services";
import { HtmlTags } from "../common/html-tags"; import { HtmlTags } from "../common/html-tags";
import { CommunityForm } from "./community-form"; import { CommunityForm } from "./community-form";
import { simpleScrollMixin } from "../mixins/scroll-mixin"; import { simpleScrollMixin } from "../mixins/scroll-mixin";
@ -68,6 +68,11 @@ export class CreateCommunity extends Component<
const res = await HttpService.client.createCommunity(form); const res = await HttpService.client.createCommunity(form);
if (res.state === "success") { 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; const name = res.data.community_view.community.name;
this.props.history.replace(`/c/${name}`); this.props.history.replace(`/c/${name}`);
} else { } else {

View file

@ -47,6 +47,8 @@ export class PrivateMessageForm extends Component<
super(props, context); super(props, context);
this.handleContentChange = this.handleContentChange.bind(this); this.handleContentChange = this.handleContentChange.bind(this);
this.handlePrivateMessageSubmit =
this.handlePrivateMessageSubmit.bind(this);
} }
componentWillReceiveProps( componentWillReceiveProps(
@ -118,9 +120,7 @@ export class PrivateMessageForm extends Component<
</label> </label>
<div className="col-sm-10"> <div className="col-sm-10">
<MarkdownTextArea <MarkdownTextArea
onSubmit={event => { onSubmit={this.handlePrivateMessageSubmit}
this.handlePrivateMessageSubmit(this, event);
}}
initialContent={this.state.content} initialContent={this.state.content}
onContentChange={this.handleContentChange} onContentChange={this.handleContentChange}
allLanguages={[]} allLanguages={[]}
@ -140,20 +140,19 @@ export class PrivateMessageForm extends Component<
); );
} }
handlePrivateMessageSubmit(i: PrivateMessageForm, event: any) { handlePrivateMessageSubmit() {
event.preventDefault(); this.setState({ loading: true, submitted: true });
i.setState({ loading: true, submitted: true }); const pm = this.props.privateMessageView;
const pm = i.props.privateMessageView; const content = this.state.content ?? "";
const content = i.state.content ?? "";
if (pm) { if (pm) {
i.props.onEdit?.({ this.props.onEdit?.({
private_message_id: pm.private_message.id, private_message_id: pm.private_message.id,
content, content,
}); });
} else { } else {
i.props.onCreate?.({ this.props.onCreate?.({
content, content,
recipient_id: i.props.recipient.id, recipient_id: this.props.recipient.id,
}); });
} }
} }