Skip to content

Commit

Permalink
refactor: replace view_create_chat by Action.CreateChat
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Feb 19, 2025
1 parent 28ed506 commit 02b8987
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/structures/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import EmbeddedPage from "./EmbeddedPage";

const onClickSendDm = (ev: ButtonEvent): void => {
PosthogTrackers.trackInteraction("WebHomeCreateChatButton", ev);
dis.dispatch({ action: "view_create_chat" });
dis.dispatch({ action: Action.CreateChat });
};

const onClickExplore = (ev: ButtonEvent): void => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/structures/MatrixChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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, "view_create_chat", "view_create_room"];
const ONBOARDING_FLOW_STARTERS = [Action.ViewUserSettings, Action.CreateChat, "view_create_room"];

interface IScreen {
screen: string;
Expand Down Expand Up @@ -816,7 +816,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
case Action.ViewStartChatOrReuse:
this.chatCreateOrReuse(payload.user_id);
break;
case "view_create_chat":
case Action.CreateChat:
showStartChatInviteDialog(payload.initialText || "");

// View the welcome or home page if we need something to look at
Expand Down Expand Up @@ -1762,7 +1762,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
});
} else if (screen === "dm") {
dis.dispatch({
action: "view_create_chat",
action: Action.CreateChat,
});
} else if (screen === "settings") {
dis.fire(Action.ViewUserSettings);
Expand Down
4 changes: 2 additions & 2 deletions src/components/views/rooms/LegacyRoomList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const DmAuxButton: React.FC<IAuxButtonProps> = ({ tabIndex, dispatcher = default
e.preventDefault();
e.stopPropagation();
closeMenu();
defaultDispatcher.dispatch({ action: "view_create_chat" });
defaultDispatcher.dispatch({ action: Action.CreateChat });
PosthogTrackers.trackInteraction(
"WebRoomListRoomsSublistPlusMenuCreateChatItem",
e,
Expand Down Expand Up @@ -194,7 +194,7 @@ const DmAuxButton: React.FC<IAuxButtonProps> = ({ tabIndex, dispatcher = default
<AccessibleButton
tabIndex={tabIndex}
onClick={(e) => {
dispatcher.dispatch({ action: "view_create_chat" });
dispatcher.dispatch({ action: Action.CreateChat });
PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateChatItem", e);
}}
className="mx_RoomSublist_auxButton"
Expand Down
8 changes: 4 additions & 4 deletions src/components/views/rooms/LegacyRoomListHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
Please see LICENSE files in the repository root for full details.
*/

import { EventType, RoomType, type Room, RoomEvent, ClientEvent } from "matrix-js-sdk/src/matrix";
import { ClientEvent, EventType, type Room, RoomEvent, RoomType } from "matrix-js-sdk/src/matrix";
import React, { useContext, useEffect, useState } from "react";
import { Tooltip } from "@vector-im/compound-web";

Expand Down Expand Up @@ -38,10 +38,10 @@ import {
} from "../../../utils/space";
import {
ChevronFace,
ContextMenuButton,
ContextMenuTooltipButton,
useContextMenu,
type MenuProps,
ContextMenuButton,
useContextMenu,
} from "../../structures/ContextMenu";
import { BetaPill } from "../beta/BetaCard";
import IconizedContextMenu, {
Expand Down Expand Up @@ -293,7 +293,7 @@ const LegacyRoomListHeader: React.FC<IProps> = ({ onVisibilityChange }) => {
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
defaultDispatcher.dispatch({ action: "view_create_chat" });
defaultDispatcher.dispatch({ action: Action.CreateChat });
PosthogTrackers.trackInteraction("WebRoomListHeaderPlusMenuCreateChatItem", e);
closePlusMenu();
}}
Expand Down
5 changes: 5 additions & 0 deletions src/dispatcher/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,9 @@ export enum Action {
* Opens right panel room summary and focuses the search input
*/
FocusMessageSearch = "focus_search",

/**
* Open the direct message dialog
*/
CreateChat = "view_create_chat",
}

0 comments on commit 02b8987

Please sign in to comment.