Skip to content

Commit 583eae6

Browse files
authored
Simplifications in InviteDialog (#33156)
* InviteDialog: simplify users section for CallTransferDialog The majority of `renderMainTab` is enpty for the call transfer dialog, so we may as well inkine the bits that aren't. * Simplify `renderMainTab` Now that this is unused for CallTransfer, we can simplify * Remove redundant eslint-disable eslint seems happy without this, and we shouldn't be disabling lints for a whole file anyway
1 parent d4aea25 commit 583eae6

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

apps/web/src/components/views/dialogs/InviteDialog.tsx

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ import { type UserProfilesStore } from "../../../stores/UserProfilesStore";
6565
import InviteProgressBody from "./InviteProgressBody.tsx";
6666
import MultiInviter, { type CompletionStates as MultiInviterCompletionStates } from "../../../utils/MultiInviter.ts";
6767

68-
// we have a number of types defined from the Matrix spec which can't reasonably be altered here.
69-
/* eslint-disable camelcase */
70-
7168
interface Result {
7269
userId: string;
7370
user: Member;
@@ -1186,8 +1183,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
11861183
}
11871184

11881185
/**
1189-
* Render content of the common "users" tab that is shown whether we have a regular invite dialog or a
1190-
* "CallTransfer" one.
1186+
* Render content of the "users" that is used for both invites and "start chat".
11911187
*/
11921188
private renderMainTab(): JSX.Element {
11931189
let helpText;
@@ -1275,26 +1271,23 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
12751271

12761272
buttonText = _t("action|invite");
12771273
goButtonFn = this.inviteUsers;
1274+
} else {
1275+
throw new Error("Unknown InviteDialog kind: " + this.props.kind);
12781276
}
12791277

1280-
const goButton =
1281-
this.props.kind == InviteKind.CallTransfer ? null : (
1282-
<AccessibleButton
1283-
kind="primary"
1284-
onClick={goButtonFn}
1285-
className="mx_InviteDialog_goButton"
1286-
disabled={this.state.busy || !this.hasSelection()}
1287-
>
1288-
{buttonText}
1289-
</AccessibleButton>
1290-
);
1291-
12921278
return (
12931279
<React.Fragment>
12941280
<p className="mx_InviteDialog_helpText">{helpText}</p>
12951281
<div className="mx_InviteDialog_addressBar">
12961282
{this.renderEditor()}
1297-
{goButton}
1283+
<AccessibleButton
1284+
kind="primary"
1285+
onClick={goButtonFn}
1286+
className="mx_InviteDialog_goButton"
1287+
disabled={this.state.busy || !this.hasSelection()}
1288+
>
1289+
{buttonText}
1290+
</AccessibleButton>
12981291
</div>
12991292
{this.state.busy ? <InviteProgressBody /> : this.renderSuggestions()}
13001293
</React.Fragment>
@@ -1342,7 +1335,12 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
13421335
* See also: {@link renderRegularDialog}.
13431336
*/
13441337
private renderCallTransferDialog(): React.ReactNode {
1345-
const usersSection = this.renderMainTab();
1338+
const usersSection = (
1339+
<React.Fragment>
1340+
<div className="mx_InviteDialog_addressBar">{this.renderEditor()}</div>
1341+
{this.state.busy ? <InviteProgressBody /> : this.renderSuggestions()}
1342+
</React.Fragment>
1343+
);
13461344

13471345
const tabs: NonEmptyArray<Tab<TabId>> = [
13481346
new Tab(

0 commit comments

Comments
 (0)