Conform more code to `strictNullChecks` and `noImplicitAny` (#11156)
parent
46eb34a55d
commit
6836a5fa7b
|
@ -686,14 +686,22 @@ async function persistCredentials(credentials: IMatrixClientCreds): Promise<void
|
||||||
// if we couldn't save to indexedDB, fall back to localStorage. We
|
// if we couldn't save to indexedDB, fall back to localStorage. We
|
||||||
// store the access token unencrypted since localStorage only saves
|
// store the access token unencrypted since localStorage only saves
|
||||||
// strings.
|
// strings.
|
||||||
localStorage.setItem("mx_access_token", credentials.accessToken);
|
if (!!credentials.accessToken) {
|
||||||
|
localStorage.setItem("mx_access_token", credentials.accessToken);
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem("mx_access_token");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
localStorage.setItem("mx_has_pickle_key", String(true));
|
localStorage.setItem("mx_has_pickle_key", String(true));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
await StorageManager.idbSave("account", "mx_access_token", credentials.accessToken);
|
await StorageManager.idbSave("account", "mx_access_token", credentials.accessToken);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
localStorage.setItem("mx_access_token", credentials.accessToken);
|
if (!!credentials.accessToken) {
|
||||||
|
localStorage.setItem("mx_access_token", credentials.accessToken);
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem("mx_access_token");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (localStorage.getItem("mx_has_pickle_key") === "true") {
|
if (localStorage.getItem("mx_has_pickle_key") === "true") {
|
||||||
logger.error("Expected a pickle key, but none provided. Encryption may not work.");
|
logger.error("Expected a pickle key, but none provided. Encryption may not work.");
|
||||||
|
|
|
@ -1597,14 +1597,15 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
private injectSticker(url: string, info: object, text: string, threadId: string | null): void {
|
private injectSticker(url: string, info: object, text: string, threadId: string | null): void {
|
||||||
if (!this.context.client) return;
|
const roomId = this.getRoomId();
|
||||||
|
if (!this.context.client || !roomId) return;
|
||||||
if (this.context.client.isGuest()) {
|
if (this.context.client.isGuest()) {
|
||||||
dis.dispatch({ action: "require_registration" });
|
dis.dispatch({ action: "require_registration" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentMessages.sharedInstance()
|
ContentMessages.sharedInstance()
|
||||||
.sendStickerContentToRoom(url, this.getRoomId(), threadId, info, text, this.context.client)
|
.sendStickerContentToRoom(url, roomId, threadId, info, text, this.context.client)
|
||||||
.then(undefined, (error) => {
|
.then(undefined, (error) => {
|
||||||
if (error.name === "UnknownDeviceError") {
|
if (error.name === "UnknownDeviceError") {
|
||||||
// Let the staus bar handle this
|
// Let the staus bar handle this
|
||||||
|
@ -1636,7 +1637,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
private onSearchUpdate = (inProgress: boolean, searchResults: ISearchResults | null): void => {
|
private onSearchUpdate = (inProgress: boolean, searchResults: ISearchResults | null): void => {
|
||||||
this.setState({
|
this.setState({
|
||||||
search: {
|
search: {
|
||||||
...this.state.search,
|
...this.state.search!,
|
||||||
count: searchResults?.count,
|
count: searchResults?.count,
|
||||||
inProgress,
|
inProgress,
|
||||||
},
|
},
|
||||||
|
@ -1658,10 +1659,12 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
private onRejectButtonClicked = (): void => {
|
private onRejectButtonClicked = (): void => {
|
||||||
|
const roomId = this.getRoomId();
|
||||||
|
if (!roomId) return;
|
||||||
this.setState({
|
this.setState({
|
||||||
rejecting: true,
|
rejecting: true,
|
||||||
});
|
});
|
||||||
this.context.client?.leave(this.getRoomId()).then(
|
this.context.client?.leave(roomId).then(
|
||||||
() => {
|
() => {
|
||||||
dis.dispatch({ action: Action.ViewHomePage });
|
dis.dispatch({ action: Action.ViewHomePage });
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -1896,14 +1899,17 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private onFileDrop = (dataTransfer: DataTransfer): Promise<void> =>
|
private onFileDrop = async (dataTransfer: DataTransfer): Promise<void> => {
|
||||||
ContentMessages.sharedInstance().sendContentListToRoom(
|
const roomId = this.getRoomId();
|
||||||
|
if (!roomId || !this.context.client) return;
|
||||||
|
await ContentMessages.sharedInstance().sendContentListToRoom(
|
||||||
Array.from(dataTransfer.files),
|
Array.from(dataTransfer.files),
|
||||||
this.getRoomId(),
|
roomId,
|
||||||
null,
|
undefined,
|
||||||
this.context.client,
|
this.context.client,
|
||||||
TimelineRenderingType.Room,
|
TimelineRenderingType.Room,
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
private onMeasurement = (narrow: boolean): void => {
|
private onMeasurement = (narrow: boolean): void => {
|
||||||
this.setState({ narrow });
|
this.setState({ narrow });
|
||||||
|
|
|
@ -830,6 +830,7 @@ export default class ScrollPanel extends React.Component<IProps> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private topFromBottom(node: HTMLElement): number {
|
private topFromBottom(node: HTMLElement): number {
|
||||||
|
if (!this.itemlist.current) return -1;
|
||||||
// current capped height - distance from top = distance from bottom of container to top of tracked element
|
// current capped height - distance from top = distance from bottom of container to top of tracked element
|
||||||
return this.itemlist.current.clientHeight - node.offsetTop;
|
return this.itemlist.current.clientHeight - node.offsetTop;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ describe("SpaceHierarchy", () => {
|
||||||
observe: () => null,
|
observe: () => null,
|
||||||
unobserve: () => null,
|
unobserve: () => null,
|
||||||
disconnect: () => null,
|
disconnect: () => null,
|
||||||
});
|
} as ResizeObserver);
|
||||||
window.IntersectionObserver = mockIntersectionObserver;
|
window.IntersectionObserver = mockIntersectionObserver;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ const mkTimeline = (room: Room, events: MatrixEvent[]): [EventTimeline, EventTim
|
||||||
room: room as Room,
|
room: room as Room,
|
||||||
getLiveTimeline: () => timeline,
|
getLiveTimeline: () => timeline,
|
||||||
getTimelineForEvent: () => timeline,
|
getTimelineForEvent: () => timeline,
|
||||||
getPendingEvents: () => [],
|
getPendingEvents: () => [] as MatrixEvent[],
|
||||||
} as unknown as EventTimelineSet;
|
} as unknown as EventTimelineSet;
|
||||||
const timeline = new EventTimeline(timelineSet);
|
const timeline = new EventTimeline(timelineSet);
|
||||||
events.forEach((event) => timeline.addEvent(event, { toStartOfTimeline: false }));
|
events.forEach((event) => timeline.addEvent(event, { toStartOfTimeline: false }));
|
||||||
|
|
|
@ -185,7 +185,7 @@ function renderComponent(props: Partial<ComponentProps<typeof VerificationPanel>
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
layout: "",
|
layout: "",
|
||||||
member: {} as User,
|
member: {} as User,
|
||||||
onClose: () => undefined,
|
onClose: () => {},
|
||||||
isRoomEncrypted: false,
|
isRoomEncrypted: false,
|
||||||
inDialog: false,
|
inDialog: false,
|
||||||
phase: props.request.phase,
|
phase: props.request.phase,
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { render, screen, fireEvent, act } from "@testing-library/react";
|
import { render, screen, fireEvent, act } from "@testing-library/react";
|
||||||
import { mocked } from "jest-mock";
|
import { mocked } from "jest-mock";
|
||||||
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
import { MatrixClient, Room } from "matrix-js-sdk/src/matrix";
|
||||||
|
|
||||||
import UnwrappedSpacePanel from "../../../../src/components/views/spaces/SpacePanel";
|
import UnwrappedSpacePanel from "../../../../src/components/views/spaces/SpacePanel";
|
||||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||||
|
@ -28,6 +28,7 @@ import { mkStubRoom, wrapInSdkContext } from "../../../test-utils";
|
||||||
import { SdkContextClass } from "../../../../src/contexts/SDKContext";
|
import { SdkContextClass } from "../../../../src/contexts/SDKContext";
|
||||||
import SpaceStore from "../../../../src/stores/spaces/SpaceStore";
|
import SpaceStore from "../../../../src/stores/spaces/SpaceStore";
|
||||||
import DMRoomMap from "../../../../src/utils/DMRoomMap";
|
import DMRoomMap from "../../../../src/utils/DMRoomMap";
|
||||||
|
import { SpaceNotificationState } from "../../../../src/stores/notifications/SpaceNotificationState";
|
||||||
|
|
||||||
// DND test utilities based on
|
// DND test utilities based on
|
||||||
// https://github.com/colinrobertbrooks/react-beautiful-dnd-test-utils/issues/18#issuecomment-1373388693
|
// https://github.com/colinrobertbrooks/react-beautiful-dnd-test-utils/issues/18#issuecomment-1373388693
|
||||||
|
@ -98,8 +99,8 @@ jest.mock("../../../../src/stores/spaces/SpaceStore", () => {
|
||||||
enabledMetaSpaces: MetaSpace[] = [];
|
enabledMetaSpaces: MetaSpace[] = [];
|
||||||
spacePanelSpaces: string[] = [];
|
spacePanelSpaces: string[] = [];
|
||||||
activeSpace: SpaceKey = "!space1";
|
activeSpace: SpaceKey = "!space1";
|
||||||
getChildSpaces = () => [];
|
getChildSpaces = () => [] as Room[];
|
||||||
getNotificationState = () => null;
|
getNotificationState = () => null as SpaceNotificationState | null;
|
||||||
setActiveSpace = jest.fn();
|
setActiveSpace = jest.fn();
|
||||||
moveRootSpace = jest.fn();
|
moveRootSpace = jest.fn();
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ describe("AutoDiscoveryUtils", () => {
|
||||||
registrationEndpoint: "https://test.com/registration",
|
registrationEndpoint: "https://test.com/registration",
|
||||||
tokenEndpoint: "https://test.com/token",
|
tokenEndpoint: "https://test.com/token",
|
||||||
};
|
};
|
||||||
const discoveryResult = {
|
const discoveryResult: ClientConfig = {
|
||||||
...validIsConfig,
|
...validIsConfig,
|
||||||
...validHsConfig,
|
...validHsConfig,
|
||||||
[M_AUTHENTICATION.stable!]: {
|
[M_AUTHENTICATION.stable!]: {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import fetchMockJest from "fetch-mock-jest";
|
||||||
import { OidcError } from "matrix-js-sdk/src/oidc/error";
|
import { OidcError } from "matrix-js-sdk/src/oidc/error";
|
||||||
|
|
||||||
import { getOidcClientId } from "../../../src/utils/oidc/registerClient";
|
import { getOidcClientId } from "../../../src/utils/oidc/registerClient";
|
||||||
|
import { ValidatedDelegatedAuthConfig } from "../../../src/utils/ValidatedServerConfig";
|
||||||
|
|
||||||
describe("getOidcClientId()", () => {
|
describe("getOidcClientId()", () => {
|
||||||
const issuer = "https://auth.com/";
|
const issuer = "https://auth.com/";
|
||||||
|
@ -49,7 +50,7 @@ describe("getOidcClientId()", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should throw when no static clientId is configured and no registration endpoint", async () => {
|
it("should throw when no static clientId is configured and no registration endpoint", async () => {
|
||||||
const authConfigWithoutRegistration = {
|
const authConfigWithoutRegistration: ValidatedDelegatedAuthConfig = {
|
||||||
...delegatedAuthConfig,
|
...delegatedAuthConfig,
|
||||||
issuer: "https://issuerWithoutStaticClientId.org/",
|
issuer: "https://issuerWithoutStaticClientId.org/",
|
||||||
registrationEndpoint: undefined,
|
registrationEndpoint: undefined,
|
||||||
|
@ -62,7 +63,7 @@ describe("getOidcClientId()", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle when staticOidcClients object is falsy", async () => {
|
it("should handle when staticOidcClients object is falsy", async () => {
|
||||||
const authConfigWithoutRegistration = {
|
const authConfigWithoutRegistration: ValidatedDelegatedAuthConfig = {
|
||||||
...delegatedAuthConfig,
|
...delegatedAuthConfig,
|
||||||
registrationEndpoint: undefined,
|
registrationEndpoint: undefined,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue