diff --git a/src/Lifecycle.ts b/src/Lifecycle.ts index 9a2f6809508..c3366cdc5c5 100644 --- a/src/Lifecycle.ts +++ b/src/Lifecycle.ts @@ -686,14 +686,22 @@ async function persistCredentials(credentials: IMatrixClientCreds): Promise { }; 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()) { dis.dispatch({ action: "require_registration" }); return; } ContentMessages.sharedInstance() - .sendStickerContentToRoom(url, this.getRoomId(), threadId, info, text, this.context.client) + .sendStickerContentToRoom(url, roomId, threadId, info, text, this.context.client) .then(undefined, (error) => { if (error.name === "UnknownDeviceError") { // Let the staus bar handle this @@ -1636,7 +1637,7 @@ export class RoomView extends React.Component { private onSearchUpdate = (inProgress: boolean, searchResults: ISearchResults | null): void => { this.setState({ search: { - ...this.state.search, + ...this.state.search!, count: searchResults?.count, inProgress, }, @@ -1658,10 +1659,12 @@ export class RoomView extends React.Component { }; private onRejectButtonClicked = (): void => { + const roomId = this.getRoomId(); + if (!roomId) return; this.setState({ rejecting: true, }); - this.context.client?.leave(this.getRoomId()).then( + this.context.client?.leave(roomId).then( () => { dis.dispatch({ action: Action.ViewHomePage }); this.setState({ @@ -1896,14 +1899,17 @@ export class RoomView extends React.Component { }); } - private onFileDrop = (dataTransfer: DataTransfer): Promise => - ContentMessages.sharedInstance().sendContentListToRoom( + private onFileDrop = async (dataTransfer: DataTransfer): Promise => { + const roomId = this.getRoomId(); + if (!roomId || !this.context.client) return; + await ContentMessages.sharedInstance().sendContentListToRoom( Array.from(dataTransfer.files), - this.getRoomId(), - null, + roomId, + undefined, this.context.client, TimelineRenderingType.Room, ); + }; private onMeasurement = (narrow: boolean): void => { this.setState({ narrow }); diff --git a/src/components/structures/ScrollPanel.tsx b/src/components/structures/ScrollPanel.tsx index fa7da4156fd..163ee39e03c 100644 --- a/src/components/structures/ScrollPanel.tsx +++ b/src/components/structures/ScrollPanel.tsx @@ -830,6 +830,7 @@ export default class ScrollPanel extends React.Component { } 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 return this.itemlist.current.clientHeight - node.offsetTop; } diff --git a/test/components/structures/SpaceHierarchy-test.tsx b/test/components/structures/SpaceHierarchy-test.tsx index 71584839890..1d41de41ac5 100644 --- a/test/components/structures/SpaceHierarchy-test.tsx +++ b/test/components/structures/SpaceHierarchy-test.tsx @@ -166,7 +166,7 @@ describe("SpaceHierarchy", () => { observe: () => null, unobserve: () => null, disconnect: () => null, - }); + } as ResizeObserver); window.IntersectionObserver = mockIntersectionObserver; }); diff --git a/test/components/structures/TimelinePanel-test.tsx b/test/components/structures/TimelinePanel-test.tsx index 8f98230a5c6..c01109bfa8b 100644 --- a/test/components/structures/TimelinePanel-test.tsx +++ b/test/components/structures/TimelinePanel-test.tsx @@ -70,7 +70,7 @@ const mkTimeline = (room: Room, events: MatrixEvent[]): [EventTimeline, EventTim room: room as Room, getLiveTimeline: () => timeline, getTimelineForEvent: () => timeline, - getPendingEvents: () => [], + getPendingEvents: () => [] as MatrixEvent[], } as unknown as EventTimelineSet; const timeline = new EventTimeline(timelineSet); events.forEach((event) => timeline.addEvent(event, { toStartOfTimeline: false })); diff --git a/test/components/views/right_panel/VerificationPanel-test.tsx b/test/components/views/right_panel/VerificationPanel-test.tsx index bee4611c6df..73f927afcb9 100644 --- a/test/components/views/right_panel/VerificationPanel-test.tsx +++ b/test/components/views/right_panel/VerificationPanel-test.tsx @@ -185,7 +185,7 @@ function renderComponent(props: Partial const defaultProps = { layout: "", member: {} as User, - onClose: () => undefined, + onClose: () => {}, isRoomEncrypted: false, inDialog: false, phase: props.request.phase, diff --git a/test/components/views/spaces/SpacePanel-test.tsx b/test/components/views/spaces/SpacePanel-test.tsx index e474c3f0556..db6b64ecf41 100644 --- a/test/components/views/spaces/SpacePanel-test.tsx +++ b/test/components/views/spaces/SpacePanel-test.tsx @@ -17,7 +17,7 @@ limitations under the License. import React from "react"; import { render, screen, fireEvent, act } from "@testing-library/react"; 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 { MatrixClientPeg } from "../../../../src/MatrixClientPeg"; @@ -28,6 +28,7 @@ import { mkStubRoom, wrapInSdkContext } from "../../../test-utils"; import { SdkContextClass } from "../../../../src/contexts/SDKContext"; import SpaceStore from "../../../../src/stores/spaces/SpaceStore"; import DMRoomMap from "../../../../src/utils/DMRoomMap"; +import { SpaceNotificationState } from "../../../../src/stores/notifications/SpaceNotificationState"; // DND test utilities based on // 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[] = []; spacePanelSpaces: string[] = []; activeSpace: SpaceKey = "!space1"; - getChildSpaces = () => []; - getNotificationState = () => null; + getChildSpaces = () => [] as Room[]; + getNotificationState = () => null as SpaceNotificationState | null; setActiveSpace = jest.fn(); moveRootSpace = jest.fn(); } diff --git a/test/utils/AutoDiscoveryUtils-test.tsx b/test/utils/AutoDiscoveryUtils-test.tsx index a47532179c3..e8e5f87dc1a 100644 --- a/test/utils/AutoDiscoveryUtils-test.tsx +++ b/test/utils/AutoDiscoveryUtils-test.tsx @@ -214,7 +214,7 @@ describe("AutoDiscoveryUtils", () => { registrationEndpoint: "https://test.com/registration", tokenEndpoint: "https://test.com/token", }; - const discoveryResult = { + const discoveryResult: ClientConfig = { ...validIsConfig, ...validHsConfig, [M_AUTHENTICATION.stable!]: { diff --git a/test/utils/oidc/registerClient-test.ts b/test/utils/oidc/registerClient-test.ts index 0a45f2011ba..1e08c0085e1 100644 --- a/test/utils/oidc/registerClient-test.ts +++ b/test/utils/oidc/registerClient-test.ts @@ -18,6 +18,7 @@ import fetchMockJest from "fetch-mock-jest"; import { OidcError } from "matrix-js-sdk/src/oidc/error"; import { getOidcClientId } from "../../../src/utils/oidc/registerClient"; +import { ValidatedDelegatedAuthConfig } from "../../../src/utils/ValidatedServerConfig"; describe("getOidcClientId()", () => { 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 () => { - const authConfigWithoutRegistration = { + const authConfigWithoutRegistration: ValidatedDelegatedAuthConfig = { ...delegatedAuthConfig, issuer: "https://issuerWithoutStaticClientId.org/", registrationEndpoint: undefined, @@ -62,7 +63,7 @@ describe("getOidcClientId()", () => { }); it("should handle when staticOidcClients object is falsy", async () => { - const authConfigWithoutRegistration = { + const authConfigWithoutRegistration: ValidatedDelegatedAuthConfig = { ...delegatedAuthConfig, registrationEndpoint: undefined, };