diff --git a/src/components/structures/HomePage.tsx b/src/components/structures/HomePage.tsx index e695e7fd313..01c00427525 100644 --- a/src/components/structures/HomePage.tsx +++ b/src/components/structures/HomePage.tsx @@ -37,7 +37,7 @@ const onClickExplore = (ev: ButtonEvent): void => { const onClickNewRoom = (ev: ButtonEvent): void => { PosthogTrackers.trackInteraction("WebHomeCreateRoomButton", ev); - dis.dispatch({ action: "view_create_room" }); + dis.dispatch({ action: Action.CreateRoom }); }; interface IProps { diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index 33ecc9257a6..3d802d34ad9 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -144,7 +144,7 @@ const AUTH_SCREENS = ["register", "mobile_register", "login", "forgot_password", // Actions that are redirected through the onboarding process prior to being // re-dispatched. NOTE: some actions are non-trivial and would require // re-factoring to be included in this list in future. -const ONBOARDING_FLOW_STARTERS = [Action.ViewUserSettings, Action.CreateChat, "view_create_room"]; +const ONBOARDING_FLOW_STARTERS = [Action.ViewUserSettings, Action.CreateChat, Action.CreateRoom]; interface IScreen { screen: string; @@ -616,7 +616,10 @@ export default class MatrixChat extends React.PureComponent { } // Start the onboarding process for certain actions - if (MatrixClientPeg.get()?.isGuest() && ONBOARDING_FLOW_STARTERS.includes(payload.action)) { + if ( + MatrixClientPeg.get()?.isGuest() && + ONBOARDING_FLOW_STARTERS.includes(payload.action as unknown as Action) + ) { // This will cause `payload` to be dispatched later, once a // sync has reached the "prepared" state. Setting a matrix ID // will cause a full login and sync and finally the deferred @@ -785,7 +788,7 @@ export default class MatrixChat extends React.PureComponent { this.viewSomethingBehindModal(); break; } - case "view_create_room": + case Action.CreateRoom: this.createRoom(payload.public, payload.defaultName, payload.type); // View the welcome or home page if we need something to look at @@ -1758,7 +1761,7 @@ export default class MatrixChat extends React.PureComponent { } } else if (screen === "new") { dis.dispatch({ - action: "view_create_room", + action: Action.CreateRoom, }); } else if (screen === "dm") { dis.dispatch({ diff --git a/src/components/views/dialogs/spotlight/SpotlightDialog.tsx b/src/components/views/dialogs/spotlight/SpotlightDialog.tsx index 722920e8289..55ba42e6140 100644 --- a/src/components/views/dialogs/spotlight/SpotlightDialog.tsx +++ b/src/components/views/dialogs/spotlight/SpotlightDialog.tsx @@ -954,7 +954,7 @@ const SpotlightDialog: React.FC = ({ initialText = "", initialFilter = n className="mx_SpotlightDialog_createRoom" onClick={() => defaultDispatcher.dispatch({ - action: "view_create_room", + action: Action.CreateRoom, public: true, defaultName: capitalize(trimmedQuery), }) diff --git a/src/components/views/rooms/LegacyRoomList.tsx b/src/components/views/rooms/LegacyRoomList.tsx index 41767e9d2e1..2894255c04e 100644 --- a/src/components/views/rooms/LegacyRoomList.tsx +++ b/src/components/views/rooms/LegacyRoomList.tsx @@ -305,7 +305,7 @@ const UntaggedAuxButton: React.FC = ({ tabIndex }) => { e.preventDefault(); e.stopPropagation(); closeMenu(); - defaultDispatcher.dispatch({ action: "view_create_room" }); + defaultDispatcher.dispatch({ action: Action.CreateRoom }); PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateRoomItem", e); }} /> @@ -318,7 +318,7 @@ const UntaggedAuxButton: React.FC = ({ tabIndex }) => { e.stopPropagation(); closeMenu(); defaultDispatcher.dispatch({ - action: "view_create_room", + action: Action.CreateRoom, type: elementCallVideoRoomsEnabled ? RoomType.UnstableCall : RoomType.ElementVideo, diff --git a/src/components/views/rooms/LegacyRoomListHeader.tsx b/src/components/views/rooms/LegacyRoomListHeader.tsx index 3cde37a59a9..93be66c7736 100644 --- a/src/components/views/rooms/LegacyRoomListHeader.tsx +++ b/src/components/views/rooms/LegacyRoomListHeader.tsx @@ -304,7 +304,7 @@ const LegacyRoomListHeader: React.FC = ({ onVisibilityChange }) => { onClick={(e) => { e.preventDefault(); e.stopPropagation(); - defaultDispatcher.dispatch({ action: "view_create_room" }); + defaultDispatcher.dispatch({ action: Action.CreateRoom }); PosthogTrackers.trackInteraction("WebRoomListHeaderPlusMenuCreateRoomItem", e); closePlusMenu(); }} @@ -317,7 +317,7 @@ const LegacyRoomListHeader: React.FC = ({ onVisibilityChange }) => { e.preventDefault(); e.stopPropagation(); defaultDispatcher.dispatch({ - action: "view_create_room", + action: Action.CreateRoom, type: elementCallVideoRoomsEnabled ? RoomType.UnstableCall : RoomType.ElementVideo, }); closePlusMenu(); diff --git a/src/dispatcher/actions.ts b/src/dispatcher/actions.ts index 21f28c782a2..d3a6bc38a18 100644 --- a/src/dispatcher/actions.ts +++ b/src/dispatcher/actions.ts @@ -370,4 +370,9 @@ export enum Action { * Open the direct message dialog */ CreateChat = "view_create_chat", + + /** + * Open the create room dialog + */ + CreateRoom = "view_create_room", }