From 47877ba2da6e0457550789afe811477cfacc1e52 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 3 Aug 2023 13:56:30 +0100 Subject: [PATCH] Switch to importing matrix-js-sdk from its main export (#11360) * Switch to importing TypedEventEmitter from main js-sdk export * Switch to importing js-sdk/matrix in cypress * Remove duplicated imports * Fix lint:js-fix to run prettier last otherwise ESLint --fix may cause a mess * Add lint rule * Fix cypress-axe import * Fix cypress-axe import --- .eslintrc.js | 5 +++++ cypress/e2e/composer/composer.spec.ts | 2 +- cypress/e2e/editing/editing.spec.ts | 4 +--- cypress/e2e/invite/invite-dialog.spec.ts | 2 +- cypress/e2e/read-receipts/read-receipts.spec.ts | 3 +-- cypress/e2e/spaces/spaces.spec.ts | 4 +--- cypress/e2e/timeline/timeline.spec.ts | 3 +-- cypress/support/axe.ts | 2 +- cypress/support/client.ts | 16 +++++++++++----- package.json | 2 +- src/AddThreepid.ts | 3 ++- src/Modal.tsx | 2 +- src/components/structures/RoomSearchView.tsx | 3 +-- .../structures/WaitingForThirdPartyRoomView.tsx | 3 +-- .../tabs/user/GeneralUserSettingsTab.tsx | 3 +-- src/components/views/voip/DialPadModal.tsx | 3 +-- src/events/RelationsHelper.ts | 3 +-- src/hooks/useCall.ts | 6 ++---- src/hooks/useEventEmitter.ts | 2 +- src/models/Call.ts | 2 +- src/modules/ProxiedModuleApi.ts | 3 +-- src/stores/OwnBeaconStore.ts | 2 +- src/stores/notifications/NotificationState.ts | 2 +- src/stores/widgets/StopGapWidget.ts | 6 ++---- src/utils/oidc/authorize.ts | 3 +-- .../audio/VoiceBroadcastRecorder.ts | 2 +- .../models/VoiceBroadcastPlayback.ts | 2 +- .../models/VoiceBroadcastPreRecording.ts | 3 +-- .../models/VoiceBroadcastRecording.ts | 2 +- .../stores/VoiceBroadcastPlaybacksStore.ts | 3 +-- .../stores/VoiceBroadcastPreRecordingStore.ts | 2 +- .../stores/VoiceBroadcastRecordingsStore.ts | 3 +-- .../views/dialogs/IncomingSasDialog-test.tsx | 2 +- .../components/views/messages/MPollBody-test.tsx | 3 +-- .../views/right_panel/VerificationPanel-test.tsx | 3 +-- .../EventTile/EventTileThreadToolbar-test.tsx | 3 +-- .../views/rooms/LegacyRoomHeader-test.tsx | 2 +- .../views/rooms/SendMessageComposer-test.tsx | 5 ++--- .../EditWysiwygComposer-test.tsx | 7 +++---- .../tabs/user/SessionManagerTab-test.tsx | 6 +++--- .../spaces/SpaceSettingsVisibilityTab-test.tsx | 9 +++++++-- .../toasts/VerificationRequestToast-test.tsx | 4 +--- test/hooks/useUnreadNotifications-test.ts | 3 +-- test/models/Call-test.ts | 11 +++++++++-- .../notifications/RoomNotificationState-test.ts | 2 +- test/stores/room-list/SpaceWatcher-test.ts | 3 +-- 46 files changed, 82 insertions(+), 87 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index f863b7d138..c7b7424455 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -61,6 +61,10 @@ module.exports = { name: "matrix-js-sdk/src/index", message: "Please use matrix-js-sdk/src/matrix instead", }, + { + name: "matrix-js-sdk/src/models/typed-event-emitter", + message: "Please use matrix-js-sdk/src/matrix instead", + }, { name: "matrix-react-sdk", message: "Please use matrix-react-sdk/src/index instead", @@ -78,6 +82,7 @@ module.exports = { ], }, ], + "import/no-duplicates": ["error"], // There are too many a11y violations to fix at once // Turn violated rules off until they are fixed diff --git a/cypress/e2e/composer/composer.spec.ts b/cypress/e2e/composer/composer.spec.ts index 54e8441987..7e4d2cf986 100644 --- a/cypress/e2e/composer/composer.spec.ts +++ b/cypress/e2e/composer/composer.spec.ts @@ -15,7 +15,7 @@ limitations under the License. */ /// -import { EventType } from "matrix-js-sdk/src/@types/event"; +import { EventType } from "matrix-js-sdk/src/matrix"; import { HomeserverInstance } from "../../plugins/utils/homeserver"; import { SettingLevel } from "../../../src/settings/SettingLevel"; diff --git a/cypress/e2e/editing/editing.spec.ts b/cypress/e2e/editing/editing.spec.ts index d42877e1b0..dafe15c885 100644 --- a/cypress/e2e/editing/editing.spec.ts +++ b/cypress/e2e/editing/editing.spec.ts @@ -16,9 +16,7 @@ limitations under the License. /// -import type { EventType, MsgType } from "matrix-js-sdk/src/@types/event"; -import type { ISendEventResponse } from "matrix-js-sdk/src/@types/requests"; -import type { IContent } from "matrix-js-sdk/src/models/event"; +import type { EventType, MsgType, ISendEventResponse, IContent } from "matrix-js-sdk/src/matrix"; import { SettingLevel } from "../../../src/settings/SettingLevel"; import { HomeserverInstance } from "../../plugins/utils/homeserver"; import Chainable = Cypress.Chainable; diff --git a/cypress/e2e/invite/invite-dialog.spec.ts b/cypress/e2e/invite/invite-dialog.spec.ts index bfc96bc74b..ba6aa4040d 100644 --- a/cypress/e2e/invite/invite-dialog.spec.ts +++ b/cypress/e2e/invite/invite-dialog.spec.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import type { MatrixClient } from "matrix-js-sdk/src/client"; +import type { MatrixClient } from "matrix-js-sdk/src/matrix"; import { HomeserverInstance } from "../../plugins/utils/homeserver"; describe("Invite dialog", function () { diff --git a/cypress/e2e/read-receipts/read-receipts.spec.ts b/cypress/e2e/read-receipts/read-receipts.spec.ts index 25334f2a22..0329b0af73 100644 --- a/cypress/e2e/read-receipts/read-receipts.spec.ts +++ b/cypress/e2e/read-receipts/read-receipts.spec.ts @@ -16,8 +16,7 @@ limitations under the License. /// -import type { MatrixClient, MatrixEvent } from "matrix-js-sdk/src/matrix"; -import type { ISendEventResponse } from "matrix-js-sdk/src/@types/requests"; +import type { MatrixClient, MatrixEvent, ISendEventResponse } from "matrix-js-sdk/src/matrix"; import type { ReceiptType } from "matrix-js-sdk/src/@types/read_receipts"; import { HomeserverInstance } from "../../plugins/utils/homeserver"; diff --git a/cypress/e2e/spaces/spaces.spec.ts b/cypress/e2e/spaces/spaces.spec.ts index 13fef2a5b5..c27d6e5ad6 100644 --- a/cypress/e2e/spaces/spaces.spec.ts +++ b/cypress/e2e/spaces/spaces.spec.ts @@ -16,9 +16,7 @@ limitations under the License. /// -import type { MatrixClient } from "matrix-js-sdk/src/client"; -import type { Preset } from "matrix-js-sdk/src/@types/partials"; -import type { ICreateRoomOpts } from "matrix-js-sdk/src/@types/requests"; +import type { MatrixClient, Preset, ICreateRoomOpts } from "matrix-js-sdk/src/matrix"; import { HomeserverInstance } from "../../plugins/utils/homeserver"; import Chainable = Cypress.Chainable; import { UserCredentials } from "../../support/login"; diff --git a/cypress/e2e/timeline/timeline.spec.ts b/cypress/e2e/timeline/timeline.spec.ts index 3502655f17..adc6f8dd7a 100644 --- a/cypress/e2e/timeline/timeline.spec.ts +++ b/cypress/e2e/timeline/timeline.spec.ts @@ -16,8 +16,7 @@ limitations under the License. /// -import type { ISendEventResponse } from "matrix-js-sdk/src/@types/requests"; -import type { EventType, MsgType } from "matrix-js-sdk/src/@types/event"; +import type { ISendEventResponse, EventType, MsgType } from "matrix-js-sdk/src/matrix"; import { HomeserverInstance } from "../../plugins/utils/homeserver"; import { SettingLevel } from "../../../src/settings/SettingLevel"; import { Layout } from "../../../src/settings/enums/Layout"; diff --git a/cypress/support/axe.ts b/cypress/support/axe.ts index 38a297fe18..356c3187fb 100644 --- a/cypress/support/axe.ts +++ b/cypress/support/axe.ts @@ -18,8 +18,8 @@ limitations under the License. import "cypress-axe"; import * as axe from "axe-core"; -import { Options } from "cypress-axe"; +import type { Options } from "cypress-axe"; import Chainable = Cypress.Chainable; function terminalLog(violations: axe.Result[]): void { diff --git a/cypress/support/client.ts b/cypress/support/client.ts index fca966613e..ad3c2e239f 100644 --- a/cypress/support/client.ts +++ b/cypress/support/client.ts @@ -16,11 +16,17 @@ limitations under the License. /// -import type { FileType, Upload, UploadOpts } from "matrix-js-sdk/src/http-api"; -import type { ICreateRoomOpts, ISendEventResponse } from "matrix-js-sdk/src/@types/requests"; -import type { MatrixClient } from "matrix-js-sdk/src/client"; -import type { Room } from "matrix-js-sdk/src/models/room"; -import type { IContent, MatrixEvent } from "matrix-js-sdk/src/models/event"; +import type { + MatrixClient, + Room, + MatrixEvent, + IContent, + FileType, + Upload, + UploadOpts, + ICreateRoomOpts, + ISendEventResponse, +} from "matrix-js-sdk/src/matrix"; import type { ReceiptType } from "matrix-js-sdk/src/@types/read_receipts"; import Chainable = Cypress.Chainable; import { UserCredentials } from "./login"; diff --git a/package.json b/package.json index 25969b8430..4c39b4e61c 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "start:build": "babel src -w -s -d lib --verbose --extensions \".ts,.js\"", "lint": "yarn lint:types && yarn lint:js && yarn lint:style", "lint:js": "eslint --max-warnings 0 src test cypress && prettier --check .", - "lint:js-fix": "prettier --loglevel=warn --write . && eslint --fix src test cypress", + "lint:js-fix": "eslint --fix src test cypress && prettier --loglevel=warn --write .", "lint:types": "tsc --noEmit --jsx react && tsc --noEmit --jsx react -p cypress", "lint:style": "stylelint \"res/css/**/*.pcss\"", "test": "jest", diff --git a/src/AddThreepid.ts b/src/AddThreepid.ts index a1567d2256..2205a9c560 100644 --- a/src/AddThreepid.ts +++ b/src/AddThreepid.ts @@ -22,8 +22,9 @@ import { IRequestMsisdnTokenResponse, IRequestTokenResponse, MatrixClient, + MatrixError, + HTTPError, } from "matrix-js-sdk/src/matrix"; -import { MatrixError, HTTPError } from "matrix-js-sdk/src/matrix"; import { IThreepid } from "matrix-js-sdk/src/@types/threepids"; import Modal from "./Modal"; diff --git a/src/Modal.tsx b/src/Modal.tsx index bf9564b5f0..801d617d31 100644 --- a/src/Modal.tsx +++ b/src/Modal.tsx @@ -19,7 +19,7 @@ import React from "react"; import ReactDOM from "react-dom"; import classNames from "classnames"; import { defer, sleep } from "matrix-js-sdk/src/utils"; -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; +import { TypedEventEmitter } from "matrix-js-sdk/src/matrix"; import dis from "./dispatcher/dispatcher"; import AsyncWrapper from "./AsyncWrapper"; diff --git a/src/components/structures/RoomSearchView.tsx b/src/components/structures/RoomSearchView.tsx index 3218ff360a..d2769a8264 100644 --- a/src/components/structures/RoomSearchView.tsx +++ b/src/components/structures/RoomSearchView.tsx @@ -16,10 +16,9 @@ limitations under the License. import React, { forwardRef, useCallback, useContext, useEffect, useRef, useState } from "react"; import { ISearchResults } from "matrix-js-sdk/src/@types/search"; -import { IThreadBundledRelationship } from "matrix-js-sdk/src/models/event"; +import { IThreadBundledRelationship, MatrixEvent } from "matrix-js-sdk/src/models/event"; import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread"; import { logger } from "matrix-js-sdk/src/logger"; -import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import ScrollPanel from "./ScrollPanel"; import { SearchScope } from "../views/rooms/SearchBar"; diff --git a/src/components/structures/WaitingForThirdPartyRoomView.tsx b/src/components/structures/WaitingForThirdPartyRoomView.tsx index 3967921a2e..8b1fe716f9 100644 --- a/src/components/structures/WaitingForThirdPartyRoomView.tsx +++ b/src/components/structures/WaitingForThirdPartyRoomView.tsx @@ -14,9 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -import React from "react"; +import React, { RefObject } from "react"; import { MatrixEvent } from "matrix-js-sdk/src/matrix"; -import { RefObject } from "react"; import { useRoomContext } from "../../contexts/RoomContext"; import ResizeNotifier from "../../utils/ResizeNotifier"; diff --git a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.tsx b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.tsx index 40b7bae8b7..be6d8dd56a 100644 --- a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.tsx @@ -20,8 +20,7 @@ import React, { ReactNode } from "react"; import { SERVICE_TYPES } from "matrix-js-sdk/src/service-types"; import { IThreepid, ThreepidMedium } from "matrix-js-sdk/src/@types/threepids"; import { logger } from "matrix-js-sdk/src/logger"; -import { IDelegatedAuthConfig, M_AUTHENTICATION } from "matrix-js-sdk/src/matrix"; -import { HTTPError } from "matrix-js-sdk/src/matrix"; +import { IDelegatedAuthConfig, M_AUTHENTICATION, HTTPError } from "matrix-js-sdk/src/matrix"; import { Icon as WarningIcon } from "../../../../../../res/img/feather-customised/warning-triangle.svg"; import { UserFriendlyError, _t } from "../../../../../languageHandler"; diff --git a/src/components/views/voip/DialPadModal.tsx b/src/components/views/voip/DialPadModal.tsx index 95b38a2fb9..abed416f34 100644 --- a/src/components/views/voip/DialPadModal.tsx +++ b/src/components/views/voip/DialPadModal.tsx @@ -14,8 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import React, { ChangeEvent } from "react"; -import { createRef, SyntheticEvent } from "react"; +import React, { ChangeEvent, createRef, SyntheticEvent } from "react"; import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton"; import Field from "../elements/Field"; diff --git a/src/events/RelationsHelper.ts b/src/events/RelationsHelper.ts index e4db5fc577..9f48b17c02 100644 --- a/src/events/RelationsHelper.ts +++ b/src/events/RelationsHelper.ts @@ -14,9 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { MatrixClient, MatrixEvent, MatrixEventEvent, RelationType } from "matrix-js-sdk/src/matrix"; +import { MatrixClient, MatrixEvent, MatrixEventEvent, RelationType, TypedEventEmitter } from "matrix-js-sdk/src/matrix"; import { Relations, RelationsEvent } from "matrix-js-sdk/src/models/relations"; -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; import { IDestroyable } from "../utils/IDestroyable"; diff --git a/src/hooks/useCall.ts b/src/hooks/useCall.ts index 03bee56b9c..bfabeaf9dd 100644 --- a/src/hooks/useCall.ts +++ b/src/hooks/useCall.ts @@ -17,11 +17,9 @@ limitations under the License. import { useState, useCallback, useMemo } from "react"; import type { RoomMember } from "matrix-js-sdk/src/models/room-member"; -import { Call, ConnectionState, ElementCall, Layout } from "../models/Call"; -import { useTypedEventEmitterState } from "./useEventEmitter"; -import { CallEvent } from "../models/Call"; +import { Call, ConnectionState, ElementCall, Layout, CallEvent } from "../models/Call"; +import { useTypedEventEmitterState, useEventEmitter } from "./useEventEmitter"; import { CallStore, CallStoreEvent } from "../stores/CallStore"; -import { useEventEmitter } from "./useEventEmitter"; import SdkConfig, { DEFAULTS } from "../SdkConfig"; import { _t } from "../languageHandler"; diff --git a/src/hooks/useEventEmitter.ts b/src/hooks/useEventEmitter.ts index 54a5a7a017..9d6b91794a 100644 --- a/src/hooks/useEventEmitter.ts +++ b/src/hooks/useEventEmitter.ts @@ -15,7 +15,7 @@ limitations under the License. */ import { useRef, useEffect, useState, useCallback } from "react"; -import { ListenerMap, TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; +import { ListenerMap, TypedEventEmitter } from "matrix-js-sdk/src/matrix"; import type { EventEmitter } from "events"; diff --git a/src/models/Call.ts b/src/models/Call.ts index cc0b08466b..48c366e130 100644 --- a/src/models/Call.ts +++ b/src/models/Call.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; +import { TypedEventEmitter } from "matrix-js-sdk/src/matrix"; import { logger } from "matrix-js-sdk/src/logger"; import { randomString } from "matrix-js-sdk/src/randomstring"; import { MatrixClient } from "matrix-js-sdk/src/client"; diff --git a/src/modules/ProxiedModuleApi.ts b/src/modules/ProxiedModuleApi.ts index 0c2b75e71f..00bfa7164a 100644 --- a/src/modules/ProxiedModuleApi.ts +++ b/src/modules/ProxiedModuleApi.ts @@ -15,12 +15,11 @@ limitations under the License. */ import { ModuleApi } from "@matrix-org/react-sdk-module-api/lib/ModuleApi"; -import { TranslationStringsObject } from "@matrix-org/react-sdk-module-api/lib/types/translations"; +import { TranslationStringsObject, PlainSubstitution } from "@matrix-org/react-sdk-module-api/lib/types/translations"; import { Optional } from "matrix-events-sdk"; import { DialogContent, DialogProps } from "@matrix-org/react-sdk-module-api/lib/components/DialogContent"; import React from "react"; import { AccountAuthInfo } from "@matrix-org/react-sdk-module-api/lib/types/AccountAuthInfo"; -import { PlainSubstitution } from "@matrix-org/react-sdk-module-api/lib/types/translations"; import * as Matrix from "matrix-js-sdk/src/matrix"; import { IRegisterRequestParams } from "matrix-js-sdk/src/matrix"; diff --git a/src/stores/OwnBeaconStore.ts b/src/stores/OwnBeaconStore.ts index ad30cc2caa..2dcef5554c 100644 --- a/src/stores/OwnBeaconStore.ts +++ b/src/stores/OwnBeaconStore.ts @@ -40,8 +40,8 @@ import { sortBeaconsByLatestCreation, TimedGeoUri, watchPosition, + getCurrentPosition, } from "../utils/beacon"; -import { getCurrentPosition } from "../utils/beacon"; import { doMaybeLocalRoomAction } from "../utils/local-room"; import SettingsStore from "../settings/SettingsStore"; diff --git a/src/stores/notifications/NotificationState.ts b/src/stores/notifications/NotificationState.ts index b4db29c135..63537eb610 100644 --- a/src/stores/notifications/NotificationState.ts +++ b/src/stores/notifications/NotificationState.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; +import { TypedEventEmitter } from "matrix-js-sdk/src/matrix"; import { NotificationColor } from "./NotificationColor"; import { IDestroyable } from "../../utils/IDestroyable"; diff --git a/src/stores/widgets/StopGapWidget.ts b/src/stores/widgets/StopGapWidget.ts index 42cf56f95a..6832ac3b9c 100644 --- a/src/stores/widgets/StopGapWidget.ts +++ b/src/stores/widgets/StopGapWidget.ts @@ -35,12 +35,11 @@ import { } from "matrix-widget-api"; import { Optional } from "matrix-events-sdk"; import { EventEmitter } from "events"; -import { MatrixClient } from "matrix-js-sdk/src/client"; +import { MatrixClient, ClientEvent } from "matrix-js-sdk/src/client"; import { MatrixEvent, MatrixEventEvent } from "matrix-js-sdk/src/models/event"; import { logger } from "matrix-js-sdk/src/logger"; -import { ClientEvent } from "matrix-js-sdk/src/client"; -import { _t } from "../../languageHandler"; +import { _t, getUserLanguage } from "../../languageHandler"; import { StopGapWidgetDriver } from "./StopGapWidgetDriver"; import { WidgetMessagingStore } from "./WidgetMessagingStore"; import { MatrixClientPeg } from "../../MatrixClientPeg"; @@ -60,7 +59,6 @@ import ThemeWatcher from "../../settings/watchers/ThemeWatcher"; import { getCustomTheme } from "../../theme"; import { ElementWidgetCapabilities } from "./ElementWidgetCapabilities"; import { ELEMENT_CLIENT_ID } from "../../identifiers"; -import { getUserLanguage } from "../../languageHandler"; import { WidgetVariableCustomisations } from "../../customisations/WidgetVariables"; import { arrayFastClone } from "../../utils/arrays"; import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload"; diff --git a/src/utils/oidc/authorize.ts b/src/utils/oidc/authorize.ts index 5a11a7144b..08a8068d9a 100644 --- a/src/utils/oidc/authorize.ts +++ b/src/utils/oidc/authorize.ts @@ -14,10 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { completeAuthorizationCodeGrant } from "matrix-js-sdk/src/oidc/authorize"; +import { completeAuthorizationCodeGrant, generateOidcAuthorizationUrl } from "matrix-js-sdk/src/oidc/authorize"; import { QueryDict } from "matrix-js-sdk/src/utils"; import { OidcClientConfig } from "matrix-js-sdk/src/autodiscovery"; -import { generateOidcAuthorizationUrl } from "matrix-js-sdk/src/oidc/authorize"; import { randomString } from "matrix-js-sdk/src/randomstring"; /** diff --git a/src/voice-broadcast/audio/VoiceBroadcastRecorder.ts b/src/voice-broadcast/audio/VoiceBroadcastRecorder.ts index ab4daae830..80241de156 100644 --- a/src/voice-broadcast/audio/VoiceBroadcastRecorder.ts +++ b/src/voice-broadcast/audio/VoiceBroadcastRecorder.ts @@ -17,7 +17,7 @@ limitations under the License. import { isEqual } from "lodash"; import { Optional } from "matrix-events-sdk"; import { logger } from "matrix-js-sdk/src/logger"; -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; +import { TypedEventEmitter } from "matrix-js-sdk/src/matrix"; import { getChunkLength } from ".."; import { IRecordingUpdate, VoiceRecording } from "../../audio/VoiceRecording"; diff --git a/src/voice-broadcast/models/VoiceBroadcastPlayback.ts b/src/voice-broadcast/models/VoiceBroadcastPlayback.ts index cb45d9f29a..77f1a56f8c 100644 --- a/src/voice-broadcast/models/VoiceBroadcastPlayback.ts +++ b/src/voice-broadcast/models/VoiceBroadcastPlayback.ts @@ -21,8 +21,8 @@ import { MatrixEventEvent, MsgType, RelationType, + TypedEventEmitter, } from "matrix-js-sdk/src/matrix"; -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; import { SimpleObservable } from "matrix-widget-api"; import { logger } from "matrix-js-sdk/src/logger"; import { defer, IDeferred } from "matrix-js-sdk/src/utils"; diff --git a/src/voice-broadcast/models/VoiceBroadcastPreRecording.ts b/src/voice-broadcast/models/VoiceBroadcastPreRecording.ts index 700bda8b8a..e1fe246809 100644 --- a/src/voice-broadcast/models/VoiceBroadcastPreRecording.ts +++ b/src/voice-broadcast/models/VoiceBroadcastPreRecording.ts @@ -14,8 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { MatrixClient, Room, RoomMember } from "matrix-js-sdk/src/matrix"; -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; +import { MatrixClient, Room, RoomMember, TypedEventEmitter } from "matrix-js-sdk/src/matrix"; import { IDestroyable } from "../../utils/IDestroyable"; import { VoiceBroadcastPlaybacksStore } from "../stores/VoiceBroadcastPlaybacksStore"; diff --git a/src/voice-broadcast/models/VoiceBroadcastRecording.ts b/src/voice-broadcast/models/VoiceBroadcastRecording.ts index db6a14d4e6..81e07646a9 100644 --- a/src/voice-broadcast/models/VoiceBroadcastRecording.ts +++ b/src/voice-broadcast/models/VoiceBroadcastRecording.ts @@ -24,8 +24,8 @@ import { MatrixEventEvent, MsgType, RelationType, + TypedEventEmitter, } from "matrix-js-sdk/src/matrix"; -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; import { ChunkRecordedPayload, diff --git a/src/voice-broadcast/stores/VoiceBroadcastPlaybacksStore.ts b/src/voice-broadcast/stores/VoiceBroadcastPlaybacksStore.ts index d76241b7d1..874a0db45e 100644 --- a/src/voice-broadcast/stores/VoiceBroadcastPlaybacksStore.ts +++ b/src/voice-broadcast/stores/VoiceBroadcastPlaybacksStore.ts @@ -14,8 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { MatrixClient, MatrixEvent } from "matrix-js-sdk/src/matrix"; -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; +import { MatrixClient, MatrixEvent, TypedEventEmitter } from "matrix-js-sdk/src/matrix"; import { VoiceBroadcastPlayback, diff --git a/src/voice-broadcast/stores/VoiceBroadcastPreRecordingStore.ts b/src/voice-broadcast/stores/VoiceBroadcastPreRecordingStore.ts index 13fcd831d1..ce7ab8802b 100644 --- a/src/voice-broadcast/stores/VoiceBroadcastPreRecordingStore.ts +++ b/src/voice-broadcast/stores/VoiceBroadcastPreRecordingStore.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; +import { TypedEventEmitter } from "matrix-js-sdk/src/matrix"; import { VoiceBroadcastPreRecording } from ".."; import { IDestroyable } from "../../utils/IDestroyable"; diff --git a/src/voice-broadcast/stores/VoiceBroadcastRecordingsStore.ts b/src/voice-broadcast/stores/VoiceBroadcastRecordingsStore.ts index b484e6ef3a..13bbb9ca3e 100644 --- a/src/voice-broadcast/stores/VoiceBroadcastRecordingsStore.ts +++ b/src/voice-broadcast/stores/VoiceBroadcastRecordingsStore.ts @@ -14,8 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { MatrixClient, MatrixEvent } from "matrix-js-sdk/src/matrix"; -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; +import { MatrixClient, MatrixEvent, TypedEventEmitter } from "matrix-js-sdk/src/matrix"; import { VoiceBroadcastInfoState, diff --git a/test/components/views/dialogs/IncomingSasDialog-test.tsx b/test/components/views/dialogs/IncomingSasDialog-test.tsx index 7c4962273c..ee12dfa02d 100644 --- a/test/components/views/dialogs/IncomingSasDialog-test.tsx +++ b/test/components/views/dialogs/IncomingSasDialog-test.tsx @@ -24,7 +24,7 @@ import { VerifierEvent, VerifierEventHandlerMap, } from "matrix-js-sdk/src/crypto-api/verification"; -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; +import { TypedEventEmitter } from "matrix-js-sdk/src/matrix"; import IncomingSasDialog from "../../../../src/components/views/dialogs/IncomingSasDialog"; import { stubClient } from "../../../test-utils"; diff --git a/test/components/views/messages/MPollBody-test.tsx b/test/components/views/messages/MPollBody-test.tsx index bc77d90edd..f103dd707a 100644 --- a/test/components/views/messages/MPollBody-test.tsx +++ b/test/components/views/messages/MPollBody-test.tsx @@ -28,7 +28,7 @@ import { } from "matrix-js-sdk/src/@types/polls"; import { M_TEXT } from "matrix-js-sdk/src/@types/extensible_events"; -import { allVotes, findTopAnswer, isPollEnded } from "../../../../src/components/views/messages/MPollBody"; +import MPollBody, { allVotes, findTopAnswer, isPollEnded } from "../../../../src/components/views/messages/MPollBody"; import { IBodyProps } from "../../../../src/components/views/messages/IBodyProps"; import { flushPromises, @@ -38,7 +38,6 @@ import { setupRoomWithPollEvents, } from "../../../test-utils"; import MatrixClientContext from "../../../../src/contexts/MatrixClientContext"; -import MPollBody from "../../../../src/components/views/messages/MPollBody"; import { RoomPermalinkCreator } from "../../../../src/utils/permalinks/Permalinks"; import { MediaEventHelper } from "../../../../src/utils/MediaEventHelper"; diff --git a/test/components/views/right_panel/VerificationPanel-test.tsx b/test/components/views/right_panel/VerificationPanel-test.tsx index 1dc252c304..271135d993 100644 --- a/test/components/views/right_panel/VerificationPanel-test.tsx +++ b/test/components/views/right_panel/VerificationPanel-test.tsx @@ -16,7 +16,6 @@ limitations under the License. import { act, render, waitFor } from "@testing-library/react"; import React, { ComponentProps } from "react"; -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; import { User } from "matrix-js-sdk/src/models/user"; import { mocked, Mocked } from "jest-mock"; import { @@ -29,7 +28,7 @@ import { VerifierEvent, VerifierEventHandlerMap, } from "matrix-js-sdk/src/crypto-api/verification"; -import { Device, MatrixClient } from "matrix-js-sdk/src/matrix"; +import { TypedEventEmitter, Device, MatrixClient } from "matrix-js-sdk/src/matrix"; import VerificationPanel from "../../../../src/components/views/right_panel/VerificationPanel"; import { flushPromises, stubClient } from "../../../test-utils"; diff --git a/test/components/views/rooms/EventTile/EventTileThreadToolbar-test.tsx b/test/components/views/rooms/EventTile/EventTileThreadToolbar-test.tsx index 8c9bff2f1c..ef9d798a0e 100644 --- a/test/components/views/rooms/EventTile/EventTileThreadToolbar-test.tsx +++ b/test/components/views/rooms/EventTile/EventTileThreadToolbar-test.tsx @@ -16,8 +16,7 @@ limitations under the License. import { getByLabelText, render, RenderResult } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; -import React from "react"; -import { ComponentProps } from "react"; +import React, { ComponentProps } from "react"; import { EventTileThreadToolbar } from "../../../../../src/components/views/rooms/EventTile/EventTileThreadToolbar"; diff --git a/test/components/views/rooms/LegacyRoomHeader-test.tsx b/test/components/views/rooms/LegacyRoomHeader-test.tsx index ea16fe4b12..a68a98b161 100644 --- a/test/components/views/rooms/LegacyRoomHeader-test.tsx +++ b/test/components/views/rooms/LegacyRoomHeader-test.tsx @@ -36,13 +36,13 @@ import { setupAsyncStoreWithClient, resetAsyncStoreWithClient, mockPlatformPeg, + mkEvent, } from "../../../test-utils"; import { MatrixClientPeg } from "../../../../src/MatrixClientPeg"; import DMRoomMap from "../../../../src/utils/DMRoomMap"; import RoomHeader, { IProps as RoomHeaderProps } from "../../../../src/components/views/rooms/LegacyRoomHeader"; import { SearchScope } from "../../../../src/components/views/rooms/SearchBar"; import { E2EStatus } from "../../../../src/utils/ShieldUtils"; -import { mkEvent } from "../../../test-utils"; import { IRoomState } from "../../../../src/components/structures/RoomView"; import RoomContext from "../../../../src/contexts/RoomContext"; import SdkConfig from "../../../../src/SdkConfig"; diff --git a/test/components/views/rooms/SendMessageComposer-test.tsx b/test/components/views/rooms/SendMessageComposer-test.tsx index 39489b3dd2..50336ad379 100644 --- a/test/components/views/rooms/SendMessageComposer-test.tsx +++ b/test/components/views/rooms/SendMessageComposer-test.tsx @@ -39,7 +39,6 @@ import { RoomPermalinkCreator } from "../../../../src/utils/permalinks/Permalink import { mockPlatformPeg } from "../../../test-utils/platform"; import { doMaybeLocalRoomAction } from "../../../../src/utils/local-room"; import { addTextToComposer } from "../../../test-utils/composer"; -import dis from "../../../../src/dispatcher/dispatcher"; import SettingsStore from "../../../../src/settings/SettingsStore"; jest.mock("../../../../src/utils/local-room", () => ({ @@ -510,7 +509,7 @@ describe("", () => { msgtype: MsgType.Text, }); - expect(dis.dispatch).toHaveBeenCalledWith({ action: `effects.confetti` }); + expect(defaultDispatcher.dispatch).toHaveBeenCalledWith({ action: `effects.confetti` }); }); it("not to send chat effects on message sending for threads", () => { @@ -537,7 +536,7 @@ describe("", () => { msgtype: MsgType.Text, }); - expect(dis.dispatch).not.toHaveBeenCalledWith({ action: `effects.confetti` }); + expect(defaultDispatcher.dispatch).not.toHaveBeenCalledWith({ action: `effects.confetti` }); }); }); diff --git a/test/components/views/rooms/wysiwyg_composer/EditWysiwygComposer-test.tsx b/test/components/views/rooms/wysiwyg_composer/EditWysiwygComposer-test.tsx index 0098859ea2..c3cbcd93e3 100644 --- a/test/components/views/rooms/wysiwyg_composer/EditWysiwygComposer-test.tsx +++ b/test/components/views/rooms/wysiwyg_composer/EditWysiwygComposer-test.tsx @@ -27,7 +27,6 @@ import { EditWysiwygComposer } from "../../../../../src/components/views/rooms/w import EditorStateTransfer from "../../../../../src/utils/EditorStateTransfer"; import { Emoji } from "../../../../../src/components/views/rooms/wysiwyg_composer/components/Emoji"; import { ChevronFace } from "../../../../../src/components/structures/ContextMenu"; -import dis from "../../../../../src/dispatcher/dispatcher"; import { ComposerInsertPayload, ComposerType } from "../../../../../src/dispatcher/payloads/ComposerInsertPayload"; import { ActionPayload } from "../../../../../src/dispatcher/payloads"; import * as EmojiButton from "../../../../../src/components/views/rooms/EmojiButton"; @@ -290,8 +289,8 @@ describe("EditWysiwygComposer", () => { // RoomView is re-dispatching the composer messages. // It adds the composerType fields where the value refers if the composer is in editing or not // The listeners in the RTE ignore the message if the composerType is missing in the payload - const dispatcherRef = dis.register((payload: ActionPayload) => { - dis.dispatch({ + const dispatcherRef = defaultDispatcher.register((payload: ActionPayload) => { + defaultDispatcher.dispatch({ ...(payload as ComposerInsertPayload), composerType: ComposerType.Edit, }); @@ -301,6 +300,6 @@ describe("EditWysiwygComposer", () => { // Then await waitFor(() => expect(screen.getByRole("textbox")).toHaveTextContent(/🦫/)); - dis.unregister(dispatcherRef); + defaultDispatcher.unregister(dispatcherRef); }); }); diff --git a/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx b/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx index 3de4eff002..c36dc0d675 100644 --- a/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx +++ b/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx @@ -35,16 +35,16 @@ import { } from "matrix-js-sdk/src/matrix"; import { mocked } from "jest-mock"; -import { clearAllModals } from "../../../../../test-utils"; -import SessionManagerTab from "../../../../../../src/components/views/settings/tabs/user/SessionManagerTab"; -import MatrixClientContext from "../../../../../../src/contexts/MatrixClientContext"; import { + clearAllModals, flushPromises, getMockClientWithEventEmitter, mkPusher, mockClientMethodsUser, mockPlatformPeg, } from "../../../../../test-utils"; +import SessionManagerTab from "../../../../../../src/components/views/settings/tabs/user/SessionManagerTab"; +import MatrixClientContext from "../../../../../../src/contexts/MatrixClientContext"; import Modal from "../../../../../../src/Modal"; import LogoutDialog from "../../../../../../src/components/views/dialogs/LogoutDialog"; import { DeviceSecurityVariation, ExtendedDevice } from "../../../../../../src/components/views/settings/devices/types"; diff --git a/test/components/views/spaces/SpaceSettingsVisibilityTab-test.tsx b/test/components/views/spaces/SpaceSettingsVisibilityTab-test.tsx index 23eb668d72..9f5a66c84d 100644 --- a/test/components/views/spaces/SpaceSettingsVisibilityTab-test.tsx +++ b/test/components/views/spaces/SpaceSettingsVisibilityTab-test.tsx @@ -22,8 +22,13 @@ import { EventType, MatrixClient, Room } from "matrix-js-sdk/src/matrix"; import { GuestAccess, HistoryVisibility, JoinRule } from "matrix-js-sdk/src/@types/partials"; import _SpaceSettingsVisibilityTab from "../../../../src/components/views/spaces/SpaceSettingsVisibilityTab"; -import { createTestClient, mkEvent, wrapInMatrixClientContext } from "../../../test-utils"; -import { mkSpace, mockStateEventImplementation } from "../../../test-utils"; +import { + createTestClient, + mkEvent, + wrapInMatrixClientContext, + mkSpace, + mockStateEventImplementation, +} from "../../../test-utils"; import { MatrixClientPeg } from "../../../../src/MatrixClientPeg"; const SpaceSettingsVisibilityTab = wrapInMatrixClientContext(_SpaceSettingsVisibilityTab); diff --git a/test/components/views/toasts/VerificationRequestToast-test.tsx b/test/components/views/toasts/VerificationRequestToast-test.tsx index f5ba06f571..fe3f7886bd 100644 --- a/test/components/views/toasts/VerificationRequestToast-test.tsx +++ b/test/components/views/toasts/VerificationRequestToast-test.tsx @@ -21,9 +21,7 @@ import { VerificationRequest, VerificationRequestEvent, } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest"; -import { IMyDevice, MatrixClient } from "matrix-js-sdk/src/client"; -import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"; -import { Device } from "matrix-js-sdk/src/matrix"; +import { TypedEventEmitter, IMyDevice, MatrixClient, Device } from "matrix-js-sdk/src/matrix"; import VerificationRequestToast from "../../../../src/components/views/toasts/VerificationRequestToast"; import { diff --git a/test/hooks/useUnreadNotifications-test.ts b/test/hooks/useUnreadNotifications-test.ts index cda9fdf4a5..0bfd83351c 100644 --- a/test/hooks/useUnreadNotifications-test.ts +++ b/test/hooks/useUnreadNotifications-test.ts @@ -15,8 +15,7 @@ limitations under the License. */ import { renderHook } from "@testing-library/react-hooks"; -import { EventStatus, NotificationCountType, PendingEventOrdering } from "matrix-js-sdk/src/matrix"; -import { Room } from "matrix-js-sdk/src/matrix"; +import { EventStatus, NotificationCountType, PendingEventOrdering, Room } from "matrix-js-sdk/src/matrix"; import type { MatrixClient } from "matrix-js-sdk/src/matrix"; import { useUnreadNotifications } from "../../src/hooks/useUnreadNotifications"; diff --git a/test/models/Call-test.ts b/test/models/Call-test.ts index 110121dc2b..b52dffb050 100644 --- a/test/models/Call-test.ts +++ b/test/models/Call-test.ts @@ -29,11 +29,18 @@ import type { Mocked } from "jest-mock"; import type { MatrixClient, IMyDevice } from "matrix-js-sdk/src/client"; import type { RoomMember } from "matrix-js-sdk/src/models/room-member"; import type { ClientWidgetApi } from "matrix-widget-api"; -import { JitsiCallMemberContent, Layout } from "../../src/models/Call"; +import { + JitsiCallMemberContent, + Layout, + Call, + CallEvent, + ConnectionState, + JitsiCall, + ElementCall, +} from "../../src/models/Call"; import { stubClient, mkEvent, mkRoomMember, setupAsyncStoreWithClient, mockPlatformPeg } from "../test-utils"; import MediaDeviceHandler, { MediaDeviceKindEnum } from "../../src/MediaDeviceHandler"; import { MatrixClientPeg } from "../../src/MatrixClientPeg"; -import { Call, CallEvent, ConnectionState, JitsiCall, ElementCall } from "../../src/models/Call"; import WidgetStore from "../../src/stores/WidgetStore"; import { WidgetMessagingStore } from "../../src/stores/widgets/WidgetMessagingStore"; import ActiveWidgetStore, { ActiveWidgetStoreEvent } from "../../src/stores/ActiveWidgetStore"; diff --git a/test/stores/notifications/RoomNotificationState-test.ts b/test/stores/notifications/RoomNotificationState-test.ts index 840d2c12d6..bcd11080e8 100644 --- a/test/stores/notifications/RoomNotificationState-test.ts +++ b/test/stores/notifications/RoomNotificationState-test.ts @@ -21,8 +21,8 @@ import { EventStatus, NotificationCountType, EventType, + MatrixEvent, } from "matrix-js-sdk/src/matrix"; -import { MatrixEvent } from "matrix-js-sdk/src/matrix"; import type { MatrixClient } from "matrix-js-sdk/src/matrix"; import { mkEvent, muteRoom, stubClient } from "../../test-utils"; diff --git a/test/stores/room-list/SpaceWatcher-test.ts b/test/stores/room-list/SpaceWatcher-test.ts index 1fa5dc8c08..66afb7f170 100644 --- a/test/stores/room-list/SpaceWatcher-test.ts +++ b/test/stores/room-list/SpaceWatcher-test.ts @@ -22,9 +22,8 @@ import type { RoomListStoreClass } from "../../../src/stores/room-list/RoomListS import SettingsStore from "../../../src/settings/SettingsStore"; import SpaceStore from "../../../src/stores/spaces/SpaceStore"; import { MetaSpace, UPDATE_HOME_BEHAVIOUR } from "../../../src/stores/spaces"; -import { stubClient } from "../../test-utils"; +import { stubClient, mkSpace, emitPromise, setupAsyncStoreWithClient } from "../../test-utils"; import { SettingLevel } from "../../../src/settings/SettingLevel"; -import { mkSpace, emitPromise, setupAsyncStoreWithClient } from "../../test-utils"; import { MatrixClientPeg } from "../../../src/MatrixClientPeg"; import { SpaceFilterCondition } from "../../../src/stores/room-list/filters/SpaceFilterCondition"; import DMRoomMap from "../../../src/utils/DMRoomMap";