Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 5f3df57

Browse files
committed
Enable Sign in with QR section in Settings where the Homeserver supports it
1 parent a4ff959 commit 5f3df57

File tree

8 files changed

+12
-65
lines changed

8 files changed

+12
-65
lines changed

src/components/views/settings/devices/LoginWithQRSection.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import type { IServerVersions } from "matrix-js-sdk/src/matrix";
2020
import { _t } from "../../../../languageHandler";
2121
import AccessibleButton from "../../elements/AccessibleButton";
2222
import SettingsSubsection from "../shared/SettingsSubsection";
23-
import SettingsStore from "../../../../settings/SettingsStore";
2423

2524
interface IProps {
2625
onShowQr: () => void;
@@ -33,12 +32,10 @@ export default class LoginWithQRSection extends React.Component<IProps> {
3332
}
3433

3534
public render(): JSX.Element | null {
35+
// Needs server support for MSC3882 and MSC3886:
3636
const msc3882Supported = !!this.props.versions?.unstable_features?.["org.matrix.msc3882"];
3737
const msc3886Supported = !!this.props.versions?.unstable_features?.["org.matrix.msc3886"];
38-
39-
// Needs to be enabled as a feature + server support MSC3886 or have a default rendezvous server configured:
40-
const offerShowQr =
41-
SettingsStore.getValue("feature_qr_signin_reciprocate_show") && msc3882Supported && msc3886Supported; // We don't support configuration of a fallback at the moment so we just check the MSCs
38+
const offerShowQr = msc3882Supported && msc3886Supported;
4239

4340
// don't show anything if no method is available
4441
if (!offerShowQr) {

src/components/views/settings/tabs/user/SecurityUserSettingsTab.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,6 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
381381
}
382382

383383
const useNewSessionManager = SettingsStore.getValue("feature_new_device_manager");
384-
const showQrCodeEnabled = SettingsStore.getValue("feature_qr_signin_reciprocate_show");
385384
const devicesSection = useNewSessionManager ? null : (
386385
<>
387386
<div className="mx_SettingsTab_heading">{_t("Where you're signed in")}</div>
@@ -394,15 +393,13 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
394393
</span>
395394
<DevicesPanel />
396395
</div>
397-
{showQrCodeEnabled ? (
398-
<LoginWithQRSection onShowQr={this.onShowQRClicked} versions={this.state.versions} />
399-
) : null}
396+
<LoginWithQRSection onShowQr={this.onShowQRClicked} versions={this.state.versions} />
400397
</>
401398
);
402399

403400
const client = MatrixClientPeg.get();
404401

405-
if (showQrCodeEnabled && this.state.showLoginWithQR) {
402+
if (this.state.showLoginWithQR) {
406403
return (
407404
<div className="mx_SettingsTab mx_SecurityUserSettingsTab">
408405
<LoginWithQR

src/components/views/settings/tabs/user/SessionManagerTab.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import { deleteDevicesWithInteractiveAuth } from "../../devices/deleteDevices";
3434
import SettingsTab from "../SettingsTab";
3535
import LoginWithQRSection from "../../devices/LoginWithQRSection";
3636
import LoginWithQR, { Mode } from "../../../auth/LoginWithQR";
37-
import SettingsStore from "../../../../../settings/SettingsStore";
3837
import { useAsyncMemo } from "../../../../../hooks/useAsyncMemo";
3938
import QuestionDialog from "../../../dialogs/QuestionDialog";
4039
import { FilterVariation } from "../../devices/filter";
@@ -212,8 +211,6 @@ const SessionManagerTab: React.FC = () => {
212211

213212
const [signInWithQrMode, setSignInWithQrMode] = useState<Mode | null>();
214213

215-
const showQrCodeEnabled = SettingsStore.getValue("feature_qr_signin_reciprocate_show");
216-
217214
const onQrFinish = useCallback(() => {
218215
setSignInWithQrMode(null);
219216
}, [setSignInWithQrMode]);
@@ -222,7 +219,7 @@ const SessionManagerTab: React.FC = () => {
222219
setSignInWithQrMode(Mode.Show);
223220
}, [setSignInWithQrMode]);
224221

225-
if (showQrCodeEnabled && signInWithQrMode) {
222+
if (signInWithQrMode) {
226223
return <LoginWithQR mode={signInWithQrMode} onFinished={onQrFinish} client={matrixClient} />;
227224
}
228225

@@ -282,7 +279,7 @@ const SessionManagerTab: React.FC = () => {
282279
/>
283280
</SettingsSubsection>
284281
)}
285-
{showQrCodeEnabled ? <LoginWithQRSection onShowQr={onShowQrClicked} versions={clientVersions} /> : null}
282+
<LoginWithQRSection onShowQr={onShowQrClicked} versions={clientVersions} />
286283
</SettingsTab>
287284
);
288285
};

src/settings/Settings.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -496,16 +496,6 @@ export const SETTINGS: { [setting: string]: ISetting } = {
496496
),
497497
},
498498
},
499-
"feature_qr_signin_reciprocate_show": {
500-
isFeature: true,
501-
labsGroup: LabGroup.Experimental,
502-
supportedLevels: LEVELS_FEATURE,
503-
displayName: _td(
504-
"Allow a QR code to be shown in session manager to sign in another device " +
505-
"(requires compatible homeserver)",
506-
),
507-
default: false,
508-
},
509499
"feature_rust_crypto": {
510500
// use the rust matrix-sdk-crypto-js for crypto.
511501
isFeature: true,

test/components/views/settings/devices/LoginWithQRSection-test.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import React from "react";
2121

2222
import LoginWithQRSection from "../../../../../src/components/views/settings/devices/LoginWithQRSection";
2323
import { MatrixClientPeg } from "../../../../../src/MatrixClientPeg";
24-
import { SettingLevel } from "../../../../../src/settings/SettingLevel";
25-
import SettingsStore from "../../../../../src/settings/SettingsStore";
2624

2725
function makeClient() {
2826
return mocked({
@@ -67,22 +65,14 @@ describe("<LoginWithQRSection />", () => {
6765
expect(container).toMatchSnapshot();
6866
});
6967

70-
it("feature enabled", async () => {
71-
await SettingsStore.setValue("feature_qr_signin_reciprocate_show", null, SettingLevel.DEVICE, true);
72-
const { container } = render(getComponent());
73-
expect(container).toMatchSnapshot();
74-
});
75-
76-
it("only feature + MSC3882 enabled", async () => {
77-
await SettingsStore.setValue("feature_qr_signin_reciprocate_show", null, SettingLevel.DEVICE, true);
68+
it("only MSC3882 enabled", async () => {
7869
const { container } = render(getComponent({ versions: makeVersions({ "org.matrix.msc3882": true }) }));
7970
expect(container).toMatchSnapshot();
8071
});
8172
});
8273

8374
describe("should render panel", () => {
84-
it("enabled by feature + MSC3882 + MSC3886", async () => {
85-
await SettingsStore.setValue("feature_qr_signin_reciprocate_show", null, SettingLevel.DEVICE, true);
75+
it("MSC3882 + MSC3886", async () => {
8676
const { container } = render(
8777
getComponent({
8878
versions: makeVersions({

test/components/views/settings/devices/__snapshots__/LoginWithQRSection-test.tsx.snap

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`<LoginWithQRSection /> should not render feature enabled 1`] = `<div />`;
4-
53
exports[`<LoginWithQRSection /> should not render no support at all 1`] = `<div />`;
64

7-
exports[`<LoginWithQRSection /> should not render only feature + MSC3882 enabled 1`] = `<div />`;
5+
exports[`<LoginWithQRSection /> should not render only MSC3882 enabled 1`] = `<div />`;
86

9-
exports[`<LoginWithQRSection /> should render panel enabled by feature + MSC3882 + MSC3886 1`] = `
7+
exports[`<LoginWithQRSection /> should render panel MSC3882 + MSC3886 1`] = `
108
<div>
119
<div
1210
class="mx_SettingsSubsection"

test/components/views/settings/tabs/user/SecurityUserSettingsTab-test.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,7 @@ describe("<SecurityUserSettingsTab />", () => {
7979
expect(queryByTestId("devices-section")).toBeFalsy();
8080
});
8181

82-
it("does not render qr code login section when disabled", () => {
83-
settingsValueSpy.mockReturnValue(false);
84-
const { queryByText } = render(getComponent());
85-
86-
expect(settingsValueSpy).toHaveBeenCalledWith("feature_qr_signin_reciprocate_show");
87-
88-
expect(queryByText("Sign in with QR code")).toBeFalsy();
89-
});
90-
91-
it("renders qr code login section when enabled", async () => {
92-
settingsValueSpy.mockImplementation((settingName) => settingName === "feature_qr_signin_reciprocate_show");
82+
it("renders qr code login section", async () => {
9383
const { getByText } = render(getComponent());
9484

9585
// wait for versions call to settle
@@ -99,7 +89,6 @@ describe("<SecurityUserSettingsTab />", () => {
9989
});
10090

10191
it("enters qr code login section when show QR code button clicked", async () => {
102-
settingsValueSpy.mockImplementation((settingName) => settingName === "feature_qr_signin_reciprocate_show");
10392
const { getByText, getByTestId } = render(getComponent());
10493
// wait for versions call to settle
10594
await flushPromises();

test/components/views/settings/tabs/user/SessionManagerTab-test.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,17 +1351,7 @@ describe("<SessionManagerTab />", () => {
13511351
});
13521352
});
13531353

1354-
it("does not render qr code login section when disabled", () => {
1355-
settingsValueSpy.mockReturnValue(false);
1356-
const { queryByText } = render(getComponent());
1357-
1358-
expect(settingsValueSpy).toHaveBeenCalledWith("feature_qr_signin_reciprocate_show");
1359-
1360-
expect(queryByText("Sign in with QR code")).toBeFalsy();
1361-
});
1362-
1363-
it("renders qr code login section when enabled", async () => {
1364-
settingsValueSpy.mockImplementation((settingName) => settingName === "feature_qr_signin_reciprocate_show");
1354+
it("renders qr code login section", async () => {
13651355
const { getByText } = render(getComponent());
13661356

13671357
// wait for versions call to settle
@@ -1371,7 +1361,6 @@ describe("<SessionManagerTab />", () => {
13711361
});
13721362

13731363
it("enters qr code login section when show QR code button clicked", async () => {
1374-
settingsValueSpy.mockImplementation((settingName) => settingName === "feature_qr_signin_reciprocate_show");
13751364
const { getByText, getByTestId } = render(getComponent());
13761365
// wait for versions call to settle
13771366
await flushPromises();

0 commit comments

Comments
 (0)