diff --git a/apps/web/src/components/views/dialogs/UserSettingsDialog.tsx b/apps/web/src/components/views/dialogs/UserSettingsDialog.tsx
index 830f1e4f10..ca9ba775ee 100644
--- a/apps/web/src/components/views/dialogs/UserSettingsDialog.tsx
+++ b/apps/web/src/components/views/dialogs/UserSettingsDialog.tsx
@@ -53,6 +53,11 @@ import { EncryptionUserSettingsTab, type State } from "../settings/tabs/user/Enc
interface IProps {
initialTabId?: UserTab;
showMsc4108QrCode?: boolean;
+ /*
+ * If true, the Account tab's status control starts in custom status mode,
+ * ready for the user to enter a custom status.
+ */
+ startCustomStatus?: boolean;
/*
* The initial state of the Encryption tab.
* If undefined, the default state is used ("loading").
@@ -102,6 +107,7 @@ export default function UserSettingsDialog(props: IProps): JSX.Element {
// store these props in state as changing tabs back and forth should clear them
const [showMsc4108QrCode, setShowMsc4108QrCode] = useState(props.showMsc4108QrCode);
const [initialEncryptionState, setInitialEncryptionState] = useState(props.initialEncryptionState);
+ const [startCustomStatus, setStartCustomStatus] = useState(props.startCustomStatus);
// If the user doesn't have Recovery set up (no default Secret Storage key),
// we show an indicator on the Encryption tab.
@@ -131,7 +137,7 @@ export default function UserSettingsDialog(props: IProps): JSX.Element {
UserTab.Account,
_td("settings|account|title"),
,
- ,
+ ,
"UserSettingsGeneral",
),
);
@@ -258,6 +264,7 @@ export default function UserSettingsDialog(props: IProps): JSX.Element {
// Clear these so switching away from the tab and back to it will not show the QR code again
setShowMsc4108QrCode(false);
setInitialEncryptionState(undefined);
+ setStartCustomStatus(false);
};
const [activeToast, toastRack] = useActiveToast();
diff --git a/apps/web/src/components/views/settings/UserProfileSettings.tsx b/apps/web/src/components/views/settings/UserProfileSettings.tsx
index d2280c3a33..1507cfa296 100644
--- a/apps/web/src/components/views/settings/UserProfileSettings.tsx
+++ b/apps/web/src/components/views/settings/UserProfileSettings.tsx
@@ -107,6 +107,8 @@ interface UserProfileSettingsProps {
canSetDisplayName: boolean;
// Whether the homeserver allows the user to set their avatar.
canSetAvatar: boolean;
+ // If true, the status control starts in custom status mode, ready for the user to enter a custom status.
+ startCustomStatus?: boolean;
}
/**
@@ -116,6 +118,7 @@ const UserProfileSettings: React.FC = ({
externalAccountManagementUrl,
canSetDisplayName,
canSetAvatar,
+ startCustomStatus,
}) => {
const [avatarURL, setAvatarURL] = useState(OwnProfileStore.instance.avatarMxc);
const [displayName, setDisplayName] = useState(OwnProfileStore.instance.displayName ?? "");
@@ -243,7 +246,7 @@ const UserProfileSettings: React.FC = ({
{_t("settings|general|display_name_error")}
)}
- {userStatusEnabled && }
+ {userStatusEnabled && }
{avatarError && (
diff --git a/apps/web/src/components/views/settings/tabs/user/AccountUserSettingsTab.tsx b/apps/web/src/components/views/settings/tabs/user/AccountUserSettingsTab.tsx
index fae5d6bb11..3c5f40f361 100644
--- a/apps/web/src/components/views/settings/tabs/user/AccountUserSettingsTab.tsx
+++ b/apps/web/src/components/views/settings/tabs/user/AccountUserSettingsTab.tsx
@@ -28,6 +28,10 @@ import { SDKContext } from "../../../../../contexts/SDKContext.ts";
interface IProps {
closeSettingsFn: () => void;
+ /**
+ * If true, the status control starts in custom status mode, ready for the user to enter a custom status.
+ */
+ startCustomStatus?: boolean;
}
interface AccountSectionProps {
@@ -82,7 +86,7 @@ const ManagementSection: React.FC = ({ onDeactivateClick
);
};
-const AccountUserSettingsTab: React.FC = ({ closeSettingsFn }) => {
+const AccountUserSettingsTab: React.FC = ({ closeSettingsFn, startCustomStatus }) => {
const [externalAccountManagementUrl, setExternalAccountManagementUrl] = React.useState();
const [canMake3pidChanges, setCanMake3pidChanges] = React.useState(false);
const [canSetDisplayName, setCanSetDisplayName] = React.useState(false);
@@ -182,6 +186,7 @@ const AccountUserSettingsTab: React.FC = ({ closeSettingsFn }) => {
externalAccountManagementUrl={externalAccountManagementUrl}
canSetDisplayName={canSetDisplayName}
canSetAvatar={canSetAvatar}
+ startCustomStatus={startCustomStatus}
/>
{(!isAccountManagedExternally || canMake3pidChanges) && (
diff --git a/apps/web/src/viewmodels/status/SetStatusViewModel.test.ts b/apps/web/src/viewmodels/status/SetStatusViewModel.test.ts
index a2c55b3847..62640e57ec 100644
--- a/apps/web/src/viewmodels/status/SetStatusViewModel.test.ts
+++ b/apps/web/src/viewmodels/status/SetStatusViewModel.test.ts
@@ -215,14 +215,15 @@ describe("UserMenuSetStatusViewModel", () => {
vi.restoreAllMocks();
});
- it("dispatches ToggleUserMenu and ViewUserSettings on onSetStatusClick", async () => {
+ it("dispatches ToggleUserMenu and ViewUserSettings on onSetCustomStatusClick", async () => {
const vm = new UserMenuSetStatusViewModel({ client, ownProfileStore: mockOwnProfileStoreInstance });
- vm.onSetStatusClick();
+ vm.onSetCustomStatusClick();
await waitFor(() => {
expect(dispatchSpy).toHaveBeenCalledWith({ action: Action.ToggleUserMenu });
expect(dispatchSpy).toHaveBeenCalledWith({
action: Action.ViewUserSettings,
initialTabId: UserTab.Account,
+ props: { startCustomStatus: true },
});
});
});
diff --git a/apps/web/src/viewmodels/status/SetStatusViewModel.ts b/apps/web/src/viewmodels/status/SetStatusViewModel.ts
index e5a2f20edd..4952730a95 100644
--- a/apps/web/src/viewmodels/status/SetStatusViewModel.ts
+++ b/apps/web/src/viewmodels/status/SetStatusViewModel.ts
@@ -85,13 +85,14 @@ export class UserMenuSetStatusViewModel extends SetStatusViewModel {
super(props);
}
- public onSetStatusClick = (): void => {
+ public onSetCustomStatusClick = (): void => {
dis.dispatch({
action: Action.ToggleUserMenu,
});
dis.dispatch({
action: Action.ViewUserSettings,
initialTabId: UserTab.Account,
+ props: { startCustomStatus: true },
});
};
}
diff --git a/apps/web/test/unit-tests/components/views/settings/UserProfileSettings-test.tsx b/apps/web/test/unit-tests/components/views/settings/UserProfileSettings-test.tsx
index eea092d7f5..ac35a1a14e 100644
--- a/apps/web/test/unit-tests/components/views/settings/UserProfileSettings-test.tsx
+++ b/apps/web/test/unit-tests/components/views/settings/UserProfileSettings-test.tsx
@@ -19,6 +19,7 @@ import { mkStubRoom, stubClient } from "../../../../test-utils";
import { OwnProfileStore } from "../../../../../src/stores/OwnProfileStore";
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
import Modal from "../../../../../src/Modal";
+import SettingsStore from "../../../../../src/settings/SettingsStore";
interface MockedAvatarSettingProps {
removeAvatar: () => void;
@@ -68,12 +69,20 @@ jest.mock("@vector-im/compound-web", () => {
};
});
-const renderProfileSettings = (toastRack: Partial, client: MatrixClient) => {
+const renderProfileSettings = (
+ toastRack: Partial,
+ client: MatrixClient,
+ { startCustomStatus }: { startCustomStatus?: boolean } = {},
+) => {
return render(
-
+
,
@@ -91,6 +100,14 @@ describe("ProfileSettings", () => {
};
});
+ it("shows the custom status editor when startCustomStatus is set", async () => {
+ jest.spyOn(SettingsStore, "getValue").mockImplementation((name) => name === "feature_user_status");
+
+ renderProfileSettings(toastRack, client, { startCustomStatus: true });
+
+ expect(await screen.findByRole("textbox", { name: "What's your status?" })).toBeInTheDocument();
+ });
+
it("removes avatar", async () => {
jest.spyOn(OwnProfileStore.instance, "avatarMxc", "get").mockReturnValue("mxc://example.org/my-avatar");
renderProfileSettings(toastRack, client);
diff --git a/packages/shared-components/src/status/SetStatusView.test.tsx b/packages/shared-components/src/status/SetStatusView.test.tsx
index ef98343b36..7d7c8968fc 100644
--- a/packages/shared-components/src/status/SetStatusView.test.tsx
+++ b/packages/shared-components/src/status/SetStatusView.test.tsx
@@ -56,6 +56,16 @@ describe("SetStatusView", () => {
expect(vm.setStatus).toHaveBeenCalledWith({ emoji: "🤩", text: "Starstruck" });
});
+ it("starts in the custom editor if initialCustomMode is set", async () => {
+ const vm = new SetStatusViewModel({});
+ render();
+
+ await userEvent.type(screen.getByRole("textbox", { name: "What's your status?" }), "Happy");
+ await userEvent.click(await screen.findByRole("button", { name: "Save" }));
+
+ expect(vm.setStatus).toHaveBeenCalledWith({ emoji: "😄", text: "Happy" });
+ });
+
it("returns to the set status prompt if the custom editor is cancelled", async () => {
const vm = new SetStatusViewModel({});
render();
diff --git a/packages/shared-components/src/status/SetStatusView.tsx b/packages/shared-components/src/status/SetStatusView.tsx
index 31e1be13b7..513faaa278 100644
--- a/packages/shared-components/src/status/SetStatusView.tsx
+++ b/packages/shared-components/src/status/SetStatusView.tsx
@@ -42,11 +42,11 @@ export interface SetStatusViewSnapshot {
export interface SetStatusViewActions {
/**
- * Called when the user clicks to start setting a status.
+ * Called when the user clicks to start setting a custom status.
*
- * If falsy, the default dropdown will open for the user to choose a status.
+ * If falsy, the UI will change to allow the user to choose an emoji and enter text.
*/
- onSetStatusClick?: () => void;
+ onSetCustomStatusClick?: () => void;
/**
* Called when the user selects a preset status from the dropdown.
@@ -69,6 +69,13 @@ export type SetStatusViewModel = ViewModel {
if (value === null) return null;
@@ -129,7 +136,11 @@ export function SetStatusView({ vm }: SetStatusViewProps): JSX.Element {
const onValueChange = (value: StatusValue): void => {
if (value === "custom") {
- setCustomMode(true);
+ if (vm.onSetCustomStatusClick) {
+ vm.onSetCustomStatusClick();
+ } else {
+ setCustomMode(true);
+ }
return;
}
@@ -145,9 +156,7 @@ export function SetStatusView({ vm }: SetStatusViewProps): JSX.Element {
});
};
- return vm.onSetStatusClick ? (
- renderTrigger({ onClick: vm.onSetStatusClick })
- ) : (
+ return (
values={STATUS_KEYS}
label={null}