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

View file

@ -39,7 +39,7 @@ import WidgetUtils from "./utils/WidgetUtils";
import { textToHtmlRainbow } from "./utils/colour";
import { AddressType, getAddressType } from './UserAddress';
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 { WidgetType } from "./widgets/WidgetType";
import { Jitsi } from "./widgets/Jitsi";
@ -544,7 +544,7 @@ export const Commands = [
prom = finished.then(([useDefault]) => {
if (useDefault) {
useDefaultIdentityServer();
setToDefaultIdentityServer();
return;
}
throw newTranslatableError(

View file

@ -29,7 +29,7 @@ import { makeRoomPermalink, makeUserPermalink } from "../../../utils/permalinks/
import DMRoomMap from "../../../utils/DMRoomMap";
import SdkConfig from "../../../SdkConfig";
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 { abbreviateUrl } from "../../../utils/UrlUtils";
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.
// eslint-disable-next-line react-hooks/rules-of-hooks
useDefaultIdentityServer();
setToDefaultIdentityServer();
this.setState({ canUseIdentityServer: true, tryingIdentityServer: false });
};

View file

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

View file

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

View file

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