diff --git a/src/IConfigOptions.ts b/src/IConfigOptions.ts index 0781fca3081..501d8a3bd64 100644 --- a/src/IConfigOptions.ts +++ b/src/IConfigOptions.ts @@ -136,8 +136,6 @@ export interface IConfigOptions { admin_message_md: string; // message for how to contact the server owner when reporting an event }; - welcome_user_id?: string; - room_directory?: { servers: string[]; }; diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index 33d41b63dbb..b4d609850de 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -57,13 +57,12 @@ import "../../stores/LifecycleStore"; import "../../stores/AutoRageshakeStore"; import PageType from "../../PageTypes"; import createRoom, { IOpts } from "../../createRoom"; -import { _t, _td, getCurrentLanguage } from "../../languageHandler"; +import { _t, _td } from "../../languageHandler"; import SettingsStore from "../../settings/SettingsStore"; import ThemeController from "../../settings/controllers/ThemeController"; import { startAnyRegistrationFlow } from "../../Registration"; import ResizeNotifier from "../../utils/ResizeNotifier"; import AutoDiscoveryUtils from "../../utils/AutoDiscoveryUtils"; -import DMRoomMap from "../../utils/DMRoomMap"; import ThemeWatcher from "../../settings/watchers/ThemeWatcher"; import { FontWatcher } from "../../settings/watchers/FontWatcher"; import { storeRoomAliasInCache } from "../../RoomAliasCache"; @@ -122,7 +121,6 @@ import { ViewHomePagePayload } from "../../dispatcher/payloads/ViewHomePagePaylo import { AfterLeaveRoomPayload } from "../../dispatcher/payloads/AfterLeaveRoomPayload"; import { DoAfterSyncPreparedPayload } from "../../dispatcher/payloads/DoAfterSyncPreparedPayload"; import { ViewStartChatOrReusePayload } from "../../dispatcher/payloads/ViewStartChatOrReusePayload"; -import { SnakedObject } from "../../utils/SnakedObject"; import { leaveRoomBehaviour } from "../../utils/leave-behaviour"; import { CallStore } from "../../stores/CallStore"; import { IRoomStateEventsActionPayload } from "../../actions/MatrixActionCreators"; @@ -1138,30 +1136,13 @@ export default class MatrixChat extends React.PureComponent { } private chatCreateOrReuse(userId: string): void { - const snakedConfig = new SnakedObject(this.props.config); // Use a deferred action to reshow the dialog once the user has registered if (MatrixClientPeg.safeGet().isGuest()) { - // No point in making 2 DMs with welcome bot. This assumes view_set_mxid will - // result in a new DM with the welcome user. - if (userId !== snakedConfig.get("welcome_user_id")) { - dis.dispatch>({ - action: Action.DoAfterSyncPrepared, - deferred_action: { - action: Action.ViewStartChatOrReuse, - user_id: userId, - }, - }); - } - dis.dispatch({ - action: "require_registration", - // If the set_mxid dialog is cancelled, view /welcome because if the - // browser was pointing at /user/@someone:domain?action=chat, the URL - // needs to be reset so that they can revisit /user/.. // (and trigger - // `_chatCreateOrReuse` again) - go_welcome_on_cancel: true, - screen_after: { - screen: `user/${snakedConfig.get("welcome_user_id")}`, - params: { action: "chat" }, + dis.dispatch>({ + action: Action.DoAfterSyncPrepared, + deferred_action: { + action: Action.ViewStartChatOrReuse, + user_id: userId, }, }); return; @@ -1290,57 +1271,6 @@ export default class MatrixChat extends React.PureComponent { } } - /** - * Starts a chat with the welcome user, if the user doesn't already have one - * @returns {string} The room ID of the new room, or null if no room was created - */ - private async startWelcomeUserChat(): Promise { - const snakedConfig = new SnakedObject(this.props.config); - const welcomeUserId = snakedConfig.get("welcome_user_id"); - if (!welcomeUserId) return null; - - // We can end up with multiple tabs post-registration where the user - // might then end up with a session and we don't want them all making - // a chat with the welcome user: try to de-dupe. - // We need to wait for the first sync to complete for this to - // work though. - let waitFor: Promise; - if (!this.firstSyncComplete) { - waitFor = this.firstSyncPromise.promise; - } else { - waitFor = Promise.resolve(); - } - await waitFor; - - const welcomeUserRooms = DMRoomMap.shared().getDMRoomsForUserId(welcomeUserId); - if (welcomeUserRooms.length === 0) { - const roomId = await createRoom(MatrixClientPeg.safeGet(), { - dmUserId: snakedConfig.get("welcome_user_id"), - // Only view the welcome user if we're NOT looking at a room - andView: !this.state.currentRoomId, - spinner: false, // we're already showing one: we don't need another one - }); - // This is a bit of a hack, but since the deduplication relies - // on m.direct being up to date, we need to force a sync - // of the database, otherwise if the user goes to the other - // tab before the next save happens (a few minutes), the - // saved sync will be restored from the db and this code will - // run without the update to m.direct, making another welcome - // user room (it doesn't wait for new data from the server, just - // the saved sync to be loaded). - const saveWelcomeUser = (ev: MatrixEvent): void => { - if (ev.getType() === EventType.Direct && ev.getContent()[welcomeUserId]) { - MatrixClientPeg.safeGet().store.save(true); - MatrixClientPeg.safeGet().removeListener(ClientEvent.AccountData, saveWelcomeUser); - } - }; - MatrixClientPeg.safeGet().on(ClientEvent.AccountData, saveWelcomeUser); - - return roomId; - } - return null; - } - /** * Called when a new logged in session has started */ @@ -1390,15 +1320,7 @@ export default class MatrixChat extends React.PureComponent { } else if (MatrixClientPeg.currentUserIsJustRegistered()) { MatrixClientPeg.setJustRegisteredUserId(null); - const snakedConfig = new SnakedObject(this.props.config); - if (snakedConfig.get("welcome_user_id") && getCurrentLanguage().startsWith("en")) { - const welcomeUserRoom = await this.startWelcomeUserChat(); - if (welcomeUserRoom === null) { - // We didn't redirect to the welcome user room, so show - // the homepage. - dis.dispatch({ action: Action.ViewHomePage, justRegistered: true }); - } - } else if (ThreepidInviteStore.instance.pickBestInvite()) { + if (ThreepidInviteStore.instance.pickBestInvite()) { // The user has a 3pid invite pending - show them that const threepidInvite = ThreepidInviteStore.instance.pickBestInvite(); diff --git a/src/components/views/dialogs/InviteDialog.tsx b/src/components/views/dialogs/InviteDialog.tsx index 08fe9a1d9ab..08dbddc21d2 100644 --- a/src/components/views/dialogs/InviteDialog.tsx +++ b/src/components/views/dialogs/InviteDialog.tsx @@ -27,7 +27,6 @@ import { _t, _td } from "../../../languageHandler"; import { MatrixClientPeg } from "../../../MatrixClientPeg"; import { makeRoomPermalink, makeUserPermalink } from "../../../utils/permalinks/Permalinks"; import DMRoomMap from "../../../utils/DMRoomMap"; -import SdkConfig from "../../../SdkConfig"; import * as Email from "../../../email"; import { getDefaultIdentityServerUrl, setToDefaultIdentityServer } from "../../../utils/IdentityServerUtils"; import { buildActivityScores, buildMemberScores, compareMembers } from "../../../utils/SortMembers"; @@ -369,9 +368,6 @@ export default class InviteDialog extends React.PureComponent UserTab.Help, _td("setting|help_about|title"), "mx_UserSettingsDialog_helpIcon", - this.props.onFinished()} />, + , "UserSettingsHelpAbout", ), ); diff --git a/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx b/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx index 85b04cf7a91..c2aab39ec75 100644 --- a/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx @@ -18,9 +18,8 @@ import React, { ReactNode } from "react"; import { logger } from "matrix-js-sdk/src/logger"; import AccessibleButton from "../../../elements/AccessibleButton"; -import { _t, getCurrentLanguage } from "../../../../../languageHandler"; +import { _t } from "../../../../../languageHandler"; import SdkConfig from "../../../../../SdkConfig"; -import createRoom from "../../../../../createRoom"; import Modal from "../../../../../Modal"; import PlatformPeg from "../../../../../PlatformPeg"; import UpdateCheckButton from "../../UpdateCheckButton"; @@ -32,9 +31,7 @@ import SettingsSubsection, { SettingsSubsectionText } from "../../shared/Setting import ExternalLink from "../../../elements/ExternalLink"; import MatrixClientContext from "../../../../../contexts/MatrixClientContext"; -interface IProps { - closeSettingsFn: () => void; -} +interface IProps {} interface IState { appVersion: string | null; @@ -96,14 +93,6 @@ export default class HelpUserSettingsTab extends React.Component Modal.createDialog(BugReportDialog, {}); }; - private onStartBotChat = (): void => { - this.props.closeSettingsFn(); - createRoom(this.context, { - dmUserId: SdkConfig.get("welcome_user_id"), - andView: true, - }); - }; - private renderLegal(): ReactNode { const tocLinks = SdkConfig.get().terms_and_conditions_links; if (!tocLinks) return null; @@ -224,7 +213,7 @@ export default class HelpUserSettingsTab extends React.Component public render(): React.ReactNode { const brand = SdkConfig.get().brand; - let faqText = _t( + const faqText = _t( "setting|help_about|help_link", { brand, @@ -233,34 +222,6 @@ export default class HelpUserSettingsTab extends React.Component a: (sub) => {sub}, }, ); - if (SdkConfig.get("welcome_user_id") && getCurrentLanguage().startsWith("en")) { - faqText = ( -
- {_t( - "setting|help_about|help_link_chat_bot", - { - brand, - }, - { - a: (sub) => ( - - {sub} - - ), - }, - )} -
- - {_t("setting|help_about|chat_bot", { brand })} - -
-
- ); - } let updateButton: JSX.Element | undefined; if (this.state.canUpdate) { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 326c41c53fd..99035cf9d47 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -2397,11 +2397,9 @@ "help_about": { "access_token_detail": "Your access token gives full access to your account. Do not share it with anyone.", "brand_version": "%(brand)s version:", - "chat_bot": "Chat with %(brand)s Bot", "clear_cache_reload": "Clear cache and reload", "crypto_version": "Crypto version:", "help_link": "For help with using %(brand)s, click here.", - "help_link_chat_bot": "For help with using %(brand)s, click here or start a chat with our bot using the button below.", "homeserver": "Homeserver is %(homeserverUrl)s", "identity_server": "Identity server is %(identityServerUrl)s", "title": "Help & About", diff --git a/test/components/views/dialogs/InviteDialog-test.tsx b/test/components/views/dialogs/InviteDialog-test.tsx index a7dd7439216..95e3131bf02 100644 --- a/test/components/views/dialogs/InviteDialog-test.tsx +++ b/test/components/views/dialogs/InviteDialog-test.tsx @@ -479,7 +479,6 @@ describe("InviteDialog", () => { }); it("should not suggest users from other server when room has m.federate=false", async () => { - SdkConfig.add({ welcome_user_id: "@bot:example.org" }); room.currentState.setStateEvents([mkRoomCreateEvent(bobId, roomId, { "m.federate": false })]); render(