Make sonar happier (#9114)

* Make sonar happier

* Rename method
This commit is contained in:
Michael Telatynski 2022-07-29 12:01:15 +01:00 committed by GitHub
parent 6a8dd23d29
commit 45f6c32eb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 23 deletions

View file

@ -26,7 +26,7 @@ import { Service, startTermsFlow, TermsNotSignedError } from './Terms';
import { import {
doesAccountDataHaveIdentityServer, doesAccountDataHaveIdentityServer,
doesIdentityServerHaveTerms, doesIdentityServerHaveTerms,
useDefaultIdentityServer, setToDefaultIdentityServer,
} from './utils/IdentityServerUtils'; } from './utils/IdentityServerUtils';
import QuestionDialog from "./components/views/dialogs/QuestionDialog"; import QuestionDialog from "./components/views/dialogs/QuestionDialog";
import { abbreviateUrl } from "./utils/UrlUtils"; import { abbreviateUrl } from "./utils/UrlUtils";
@ -164,8 +164,7 @@ export default class IdentityAuthClient {
}); });
const [confirmed] = await finished; const [confirmed] = await finished;
if (confirmed) { if (confirmed) {
// eslint-disable-next-line react-hooks/rules-of-hooks setToDefaultIdentityServer();
useDefaultIdentityServer();
} else { } else {
throw new AbortedIdentityActionError( throw new AbortedIdentityActionError(
"User aborted identity server action without terms", "User aborted identity server action without terms",

View file

@ -39,7 +39,7 @@ import WidgetUtils from "./utils/WidgetUtils";
import { textToHtmlRainbow } from "./utils/colour"; import { textToHtmlRainbow } from "./utils/colour";
import { AddressType, getAddressType } from './UserAddress'; import { AddressType, getAddressType } from './UserAddress';
import { abbreviateUrl } from './utils/UrlUtils'; import { abbreviateUrl } from './utils/UrlUtils';
import { getDefaultIdentityServerUrl, useDefaultIdentityServer } from './utils/IdentityServerUtils'; import { getDefaultIdentityServerUrl, setToDefaultIdentityServer } from './utils/IdentityServerUtils';
import { isPermalinkHost, parsePermalink } from "./utils/permalinks/Permalinks"; import { isPermalinkHost, parsePermalink } from "./utils/permalinks/Permalinks";
import { WidgetType } from "./widgets/WidgetType"; import { WidgetType } from "./widgets/WidgetType";
import { Jitsi } from "./widgets/Jitsi"; import { Jitsi } from "./widgets/Jitsi";
@ -544,7 +544,7 @@ export const Commands = [
prom = finished.then(([useDefault]) => { prom = finished.then(([useDefault]) => {
if (useDefault) { if (useDefault) {
useDefaultIdentityServer(); setToDefaultIdentityServer();
return; return;
} }
throw newTranslatableError( throw newTranslatableError(

View file

@ -29,7 +29,7 @@ import { makeRoomPermalink, makeUserPermalink } from "../../../utils/permalinks/
import DMRoomMap from "../../../utils/DMRoomMap"; import DMRoomMap from "../../../utils/DMRoomMap";
import SdkConfig from "../../../SdkConfig"; import SdkConfig from "../../../SdkConfig";
import * as Email from "../../../email"; import * as Email from "../../../email";
import { getDefaultIdentityServerUrl, useDefaultIdentityServer } from "../../../utils/IdentityServerUtils"; import { getDefaultIdentityServerUrl, setToDefaultIdentityServer } from "../../../utils/IdentityServerUtils";
import { buildActivityScores, buildMemberScores, compareMembers } from "../../../utils/SortMembers"; import { buildActivityScores, buildMemberScores, compareMembers } from "../../../utils/SortMembers";
import { abbreviateUrl } from "../../../utils/UrlUtils"; import { abbreviateUrl } from "../../../utils/UrlUtils";
import IdentityAuthClient from "../../../IdentityAuthClient"; import IdentityAuthClient from "../../../IdentityAuthClient";
@ -815,7 +815,7 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
// Update the IS in account data. Actually using it may trigger terms. // Update the IS in account data. Actually using it may trigger terms.
// eslint-disable-next-line react-hooks/rules-of-hooks // eslint-disable-next-line react-hooks/rules-of-hooks
useDefaultIdentityServer(); setToDefaultIdentityServer();
this.setState({ canUseIdentityServer: true, tryingIdentityServer: false }); this.setState({ canUseIdentityServer: true, tryingIdentityServer: false });
}; };

View file

@ -16,12 +16,7 @@ limitations under the License.
import React, { useContext, useEffect, useState } from "react"; import React, { useContext, useEffect, useState } from "react";
import { import {
PHASE_CANCELLED, Phase,
PHASE_DONE,
PHASE_READY,
PHASE_REQUESTED,
PHASE_STARTED,
PHASE_UNSENT,
VerificationRequest, VerificationRequest,
VerificationRequestEvent, VerificationRequestEvent,
} from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest"; } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
@ -32,13 +27,13 @@ import { _t, _td } from "../../../../languageHandler";
import MatrixClientContext from "../../../../contexts/MatrixClientContext"; import MatrixClientContext from "../../../../contexts/MatrixClientContext";
import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool"; import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool";
const PHASE_MAP = { const PHASE_MAP: Record<Phase, string> = {
[PHASE_UNSENT]: _td("Unsent"), [Phase.Unsent]: _td("Unsent"),
[PHASE_REQUESTED]: _td("Requested"), [Phase.Requested]: _td("Requested"),
[PHASE_READY]: _td("Ready"), [Phase.Ready]: _td("Ready"),
[PHASE_DONE]: _td("Done"), [Phase.Done]: _td("Done"),
[PHASE_STARTED]: _td("Started"), [Phase.Started]: _td("Started"),
[PHASE_CANCELLED]: _td("Cancelled"), [Phase.Cancelled]: _td("Cancelled"),
}; };
const VerificationRequestExplorer: React.FC<{ const VerificationRequestExplorer: React.FC<{
@ -68,7 +63,7 @@ const VerificationRequestExplorer: React.FC<{
<dt>{ _t("Transaction") }</dt> <dt>{ _t("Transaction") }</dt>
<dd>{ txnId }</dd> <dd>{ txnId }</dd>
<dt>{ _t("Phase") }</dt> <dt>{ _t("Phase") }</dt>
<dd>{ PHASE_MAP[request.phase] || request.phase }</dd> // TODO <dd>{ PHASE_MAP[request.phase] ? _t(PHASE_MAP[request.phase]) : request.phase }</dd>
<dt>{ _t("Timeout") }</dt> <dt>{ _t("Timeout") }</dt>
<dd>{ Math.floor(timeout / 1000) }</dd> <dd>{ Math.floor(timeout / 1000) }</dd>
<dt>{ _t("Methods") }</dt> <dt>{ _t("Methods") }</dt>

View file

@ -32,9 +32,9 @@ const TIMEOUT = 1500;
export function UseCaseSelection({ onFinished }: Props) { export function UseCaseSelection({ onFinished }: Props) {
const [selection, setSelected] = useState<UseCase | null>(null); const [selection, setSelected] = useState<UseCase | null>(null);
// Call onFinished 1.5s after `selection` becomes truthy, to give time for the animation to run
useEffect(() => { useEffect(() => {
if (selection) { if (selection) {
setSelected(selection);
let handler: number | null = setTimeout(() => { let handler: number | null = setTimeout(() => {
handler = null; handler = null;
onFinished(selection); onFinished(selection);

View file

@ -24,7 +24,7 @@ export function getDefaultIdentityServerUrl(): string {
return SdkConfig.get("validated_server_config").isUrl; return SdkConfig.get("validated_server_config").isUrl;
} }
export function useDefaultIdentityServer(): void { export function setToDefaultIdentityServer(): void {
const url = getDefaultIdentityServerUrl(); const url = getDefaultIdentityServerUrl();
// Account data change will update localstorage, client, etc through dispatcher // Account data change will update localstorage, client, etc through dispatcher
MatrixClientPeg.get().setAccountData("m.identity_server", { MatrixClientPeg.get().setAccountData("m.identity_server", {