From 7fe40a04701bdd0163359bd02f5cd786b4ed6cfc Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 12 May 2020 10:55:46 +0100 Subject: [PATCH] Default to public room when creating room from room directory Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/MatrixChat.tsx | 6 +++--- src/components/structures/RoomDirectory.js | 5 ++++- src/components/views/dialogs/CreateRoomDialog.js | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index 3929711406..e553057acb 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -623,7 +623,7 @@ export default class MatrixChat extends React.PureComponent { break; } case 'view_create_room': - this.createRoom(); + this.createRoom(payload.public); break; case 'view_create_group': { const CreateGroupDialog = sdk.getComponent("dialogs.CreateGroupDialog"); @@ -1012,9 +1012,9 @@ export default class MatrixChat extends React.PureComponent { }).close; } - private async createRoom() { + private async createRoom(defaultPublic = false) { const CreateRoomDialog = sdk.getComponent('dialogs.CreateRoomDialog'); - const modal = Modal.createTrackedDialog('Create Room', '', CreateRoomDialog); + const modal = Modal.createTrackedDialog('Create Room', '', CreateRoomDialog, { defaultPublic }); const [shouldCreate, opts] = await modal.finished; if (shouldCreate) { diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js index 0b07c10c8a..86353cd532 100644 --- a/src/components/structures/RoomDirectory.js +++ b/src/components/structures/RoomDirectory.js @@ -367,7 +367,10 @@ export default createReactClass({ onCreateRoomClick: function(room) { this.props.onFinished(); - dis.dispatch({action: 'view_create_room'}); + dis.dispatch({ + action: 'view_create_room', + public: true, + }); }, showRoomAlias: function(alias, autoJoin=false) { diff --git a/src/components/views/dialogs/CreateRoomDialog.js b/src/components/views/dialogs/CreateRoomDialog.js index 74e006354b..fb08afa5f7 100644 --- a/src/components/views/dialogs/CreateRoomDialog.js +++ b/src/components/views/dialogs/CreateRoomDialog.js @@ -30,12 +30,13 @@ export default createReactClass({ displayName: 'CreateRoomDialog', propTypes: { onFinished: PropTypes.func.isRequired, + defaultPublic: PropTypes.bool, }, getInitialState() { const config = SdkConfig.get(); return { - isPublic: false, + isPublic: this.props.defaultPublic || false, isEncrypted: true, name: "", topic: "",