Move room name, avatar, and topic to IOpts. (#30981)
This commit is contained in:
@@ -329,8 +329,8 @@ const SpaceSetupFirstRooms: React.FC<{
|
||||
return createRoom(space.client, {
|
||||
createOpts: {
|
||||
preset: isPublic ? Preset.PublicChat : Preset.PrivateChat,
|
||||
name,
|
||||
},
|
||||
name,
|
||||
spinner: false,
|
||||
encryption: false,
|
||||
andView: false,
|
||||
@@ -423,7 +423,7 @@ const SpaceSetupPublicShare: React.FC<ISpaceSetupPublicShareProps> = ({
|
||||
<div className="mx_SpaceRoomView_publicShare">
|
||||
<h1>
|
||||
{_t("create_space|share_heading", {
|
||||
name: justCreatedOpts?.createOpts?.name || space.name,
|
||||
name: justCreatedOpts?.name || space.name,
|
||||
})}
|
||||
</h1>
|
||||
<div className="mx_SpaceRoomView_description">{_t("create_space|share_description")}</div>
|
||||
@@ -449,7 +449,7 @@ const SpaceSetupPrivateScope: React.FC<{
|
||||
<h1>{_t("create_space|private_personal_heading")}</h1>
|
||||
<div className="mx_SpaceRoomView_description">
|
||||
{_t("create_space|private_personal_description", {
|
||||
name: justCreatedOpts?.createOpts?.name || space.name,
|
||||
name: justCreatedOpts?.name || space.name,
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -686,7 +686,7 @@ export default class SpaceRoomView extends React.PureComponent<IProps, IState> {
|
||||
<SpaceSetupFirstRooms
|
||||
space={this.props.space}
|
||||
title={_t("create_space|setup_rooms_community_heading", {
|
||||
spaceName: this.props.justCreatedOpts?.createOpts?.name || this.props.space.name,
|
||||
spaceName: this.props.justCreatedOpts?.name || this.props.space.name,
|
||||
})}
|
||||
description={
|
||||
<>
|
||||
|
||||
@@ -126,7 +126,7 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
|
||||
const opts: IOpts = {};
|
||||
const createOpts: IOpts["createOpts"] = (opts.createOpts = {});
|
||||
opts.roomType = this.props.type;
|
||||
createOpts.name = this.state.name;
|
||||
opts.name = this.state.name;
|
||||
|
||||
if (this.state.joinRule === JoinRule.Public) {
|
||||
createOpts.visibility = Visibility.Public;
|
||||
@@ -139,7 +139,7 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
|
||||
}
|
||||
|
||||
if (this.state.topic) {
|
||||
createOpts.topic = this.state.topic;
|
||||
opts.topic = this.state.topic;
|
||||
}
|
||||
if (this.state.noFederate) {
|
||||
createOpts.creation_content = { "m.federate": false };
|
||||
|
||||
@@ -49,7 +49,19 @@ import { ElementCallEventType, ElementCallMemberEventType } from "./call-types";
|
||||
|
||||
export interface IOpts {
|
||||
dmUserId?: string;
|
||||
createOpts?: ICreateRoomOpts;
|
||||
/**
|
||||
* The name of the room to be created.
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* The topic for the room.
|
||||
*/
|
||||
topic?: string;
|
||||
/**
|
||||
* Additional options to pass to the room creation API.
|
||||
* Note: "name", "topic", and "avatar" should be set via their respective properties in IOpts.
|
||||
*/
|
||||
createOpts?: Omit<ICreateRoomOpts, "name" | "topic" | "avatar">;
|
||||
spinner?: boolean;
|
||||
guestAccess?: boolean;
|
||||
encryption?: boolean;
|
||||
@@ -251,6 +263,14 @@ export default async function createRoom(client: MatrixClient, opts: IOpts): Pro
|
||||
});
|
||||
}
|
||||
|
||||
if (opts.name) {
|
||||
createOpts.name = opts.name;
|
||||
}
|
||||
|
||||
if (opts.topic) {
|
||||
createOpts.topic = opts.topic;
|
||||
}
|
||||
|
||||
if (opts.avatar) {
|
||||
let url = opts.avatar;
|
||||
if (opts.avatar instanceof File) {
|
||||
|
||||
Reference in New Issue
Block a user