Move DeviceListener into the device-listener directory (#32434)
* Move DeviceListener into the device-listener dir * Provide device-listener/index.ts
This commit is contained in:
2
src/@types/global.d.ts
vendored
2
src/@types/global.d.ts
vendored
@@ -15,7 +15,7 @@ import type { logger } from "matrix-js-sdk/src/logger";
|
||||
import type ContentMessages from "../ContentMessages";
|
||||
import { type IMatrixClientPeg } from "../MatrixClientPeg";
|
||||
import type ToastStore from "../stores/ToastStore";
|
||||
import type DeviceListener from "../DeviceListener";
|
||||
import { type DeviceListener } from "../device-listener";
|
||||
import { type RoomListStore } from "../stores/room-list/Interface";
|
||||
import { type PlatformPeg } from "../PlatformPeg";
|
||||
import type RoomListLayoutStore from "../stores/room-list/RoomListLayoutStore";
|
||||
|
||||
@@ -41,7 +41,7 @@ import { SettingLevel } from "./settings/SettingLevel";
|
||||
import ToastStore from "./stores/ToastStore";
|
||||
import { IntegrationManagers } from "./integrations/IntegrationManagers";
|
||||
import { Mjolnir } from "./mjolnir/Mjolnir";
|
||||
import DeviceListener from "./DeviceListener";
|
||||
import { DeviceListener } from "./device-listener";
|
||||
import { Jitsi } from "./widgets/Jitsi";
|
||||
import { SSO_HOMESERVER_URL_KEY, SSO_ID_SERVER_URL_KEY, SSO_IDP_ID_KEY } from "./BasePlatform";
|
||||
import ThreepidInviteStore from "./stores/ThreepidInviteStore";
|
||||
|
||||
@@ -10,10 +10,9 @@ import { CryptoEvent } from "matrix-js-sdk/src/crypto-api";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import { useMatrixClientContext } from "../../../../contexts/MatrixClientContext";
|
||||
import DeviceListener from "../../../../DeviceListener";
|
||||
import { DeviceListener, BACKUP_DISABLED_ACCOUNT_DATA_KEY } from "../../../../device-listener";
|
||||
import { useEventEmitterAsyncState } from "../../../../hooks/useEventEmitter";
|
||||
import { resetKeyBackupAndWait } from "../../../../utils/crypto/resetKeyBackup";
|
||||
import { BACKUP_DISABLED_ACCOUNT_DATA_KEY } from "../../../../device-listener/DeviceListenerCurrentDevice";
|
||||
|
||||
interface KeyStoragePanelState {
|
||||
/**
|
||||
|
||||
@@ -31,9 +31,8 @@ import { initialiseDehydrationIfEnabled } from "../../../../utils/device/dehydra
|
||||
import { withSecretStorageKeyCache } from "../../../../SecurityManager";
|
||||
import { EncryptionCardButtons } from "./EncryptionCardButtons";
|
||||
import { logErrorAndShowErrorDialog } from "../../../../utils/ErrorUtils.tsx";
|
||||
import DeviceListener from "../../../../DeviceListener";
|
||||
import { DeviceListener, RECOVERY_ACCOUNT_DATA_KEY } from "../../../../device-listener";
|
||||
import { resetKeyBackupAndWait } from "../../../../utils/crypto/resetKeyBackup";
|
||||
import { RECOVERY_ACCOUNT_DATA_KEY } from "../../../../device-listener/DeviceListenerCurrentDevice.ts";
|
||||
|
||||
/**
|
||||
* The possible states of the component.
|
||||
|
||||
@@ -14,7 +14,7 @@ import { SettingsSection } from "../shared/SettingsSection";
|
||||
import { _t } from "../../../../languageHandler";
|
||||
import { SettingsSubheader } from "../SettingsSubheader";
|
||||
import { AccessCancelledError, accessSecretStorage } from "../../../../SecurityManager";
|
||||
import DeviceListener from "../../../../DeviceListener";
|
||||
import { DeviceListener } from "../../../../device-listener";
|
||||
import { useMatrixClientContext } from "../../../../contexts/MatrixClientContext";
|
||||
import { resetKeyBackupAndWait } from "../../../../utils/crypto/resetKeyBackup";
|
||||
|
||||
|
||||
@@ -24,9 +24,8 @@ import { RecoveryPanelOutOfSync } from "../../encryption/RecoveryPanelOutOfSync"
|
||||
import { useTypedEventEmitterState } from "../../../../../hooks/useEventEmitter";
|
||||
import { KeyStoragePanel } from "../../encryption/KeyStoragePanel";
|
||||
import { DeleteKeyStoragePanel } from "../../encryption/DeleteKeyStoragePanel";
|
||||
import DeviceListener, { DeviceListenerEvents } from "../../../../../DeviceListener";
|
||||
import { DeviceListener, DeviceListenerEvents, type DeviceState } from "../../../../../device-listener";
|
||||
import { useKeyStoragePanelViewModel } from "../../../../viewmodels/settings/encryption/KeyStoragePanelViewModel";
|
||||
import type DeviceState from "../../../../../device-listener/DeviceState";
|
||||
|
||||
/**
|
||||
* The state in the encryption settings tab.
|
||||
|
||||
@@ -12,17 +12,15 @@ import { logger as baseLogger, LogSpan } from "matrix-js-sdk/src/logger";
|
||||
import { type CryptoSessionStateChange } from "@matrix-org/analytics-events/types/typescript/CryptoSessionStateChange";
|
||||
import { secureRandomString } from "matrix-js-sdk/src/randomstring";
|
||||
|
||||
import { PosthogAnalytics } from "./PosthogAnalytics";
|
||||
import dis from "./dispatcher/dispatcher";
|
||||
import { type ActionPayload } from "./dispatcher/payloads";
|
||||
import { Action } from "./dispatcher/actions";
|
||||
import SdkConfig from "./SdkConfig";
|
||||
import PlatformPeg from "./PlatformPeg";
|
||||
import { recordClientInformation, removeClientInformation } from "./utils/device/clientInformation";
|
||||
import SettingsStore, { type CallbackFn } from "./settings/SettingsStore";
|
||||
import DeviceListenerOtherDevices from "./device-listener/DeviceListenerOtherDevices.ts";
|
||||
import DeviceListenerCurrentDevice from "./device-listener/DeviceListenerCurrentDevice.ts";
|
||||
import type DeviceState from "./device-listener/DeviceState.ts";
|
||||
import { PosthogAnalytics } from "../PosthogAnalytics";
|
||||
import dis from "../dispatcher/dispatcher";
|
||||
import { type ActionPayload } from "../dispatcher/payloads";
|
||||
import { Action } from "../dispatcher/actions";
|
||||
import SdkConfig from "../SdkConfig";
|
||||
import PlatformPeg from "../PlatformPeg";
|
||||
import { recordClientInformation, removeClientInformation } from "../utils/device/clientInformation";
|
||||
import SettingsStore, { type CallbackFn } from "../settings/SettingsStore";
|
||||
import { DeviceListenerOtherDevices, DeviceListenerCurrentDevice, type DeviceState } from ".";
|
||||
|
||||
const logger = baseLogger.getChild("DeviceListener:");
|
||||
|
||||
@@ -37,7 +35,7 @@ type EventHandlerMap = {
|
||||
[DeviceListenerEvents.DeviceState]: (state: DeviceState) => void;
|
||||
};
|
||||
|
||||
export default class DeviceListener extends TypedEventEmitter<DeviceListenerEvents, EventHandlerMap> {
|
||||
export class DeviceListener extends TypedEventEmitter<DeviceListenerEvents, EventHandlerMap> {
|
||||
private dispatcherRef?: string;
|
||||
|
||||
/**
|
||||
@@ -18,9 +18,7 @@ import {
|
||||
ClientEvent,
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import type DeviceListener from "../DeviceListener";
|
||||
import type DeviceState from "./DeviceState";
|
||||
import { DeviceListenerEvents } from "../DeviceListener";
|
||||
import { type DeviceListener, type DeviceState, DeviceListenerEvents } from ".";
|
||||
import {
|
||||
hideToast as hideSetupEncryptionToast,
|
||||
showToast as showSetupEncryptionToast,
|
||||
@@ -46,7 +44,7 @@ export const RECOVERY_ACCOUNT_DATA_KEY = "io.element.recovery";
|
||||
/**
|
||||
* Handles all of DeviceListener's work that relates to the current device.
|
||||
*/
|
||||
export default class DeviceListenerCurrentDevice {
|
||||
export class DeviceListenerCurrentDevice {
|
||||
/**
|
||||
* The DeviceListener launching this instance.
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,7 @@ import { CryptoEvent } from "matrix-js-sdk/src/crypto-api";
|
||||
import { type LogSpan } from "matrix-js-sdk/src/logger";
|
||||
import { type MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import type DeviceListener from "../DeviceListener";
|
||||
import { type DeviceListener } from ".";
|
||||
import { getUserDeviceIds } from "../utils/crypto/deviceInfo";
|
||||
import { isBulkUnverifiedDeviceReminderSnoozed } from "../utils/device/snoozeBulkUnverifiedDeviceReminder";
|
||||
import {
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
showToast as showUnverifiedSessionToast,
|
||||
} from "../toasts/UnverifiedSessionToast";
|
||||
|
||||
export default class DeviceListenerOtherDevices {
|
||||
export class DeviceListenerOtherDevices {
|
||||
/**
|
||||
* The DeviceListener launching this instance.
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
/**
|
||||
* The state of the device and the user's account.
|
||||
*/
|
||||
type DeviceState =
|
||||
export type DeviceState =
|
||||
/**
|
||||
* The device is in a good state.
|
||||
*/
|
||||
@@ -35,5 +35,3 @@ type DeviceState =
|
||||
* The user's identity needs resetting, due to missing keys.
|
||||
*/
|
||||
| "identity_needs_reset";
|
||||
|
||||
export default DeviceState;
|
||||
|
||||
11
src/device-listener/index.ts
Normal file
11
src/device-listener/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Copyright 2026 Element Creations Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
export * from "./DeviceListener";
|
||||
export * from "./DeviceListenerCurrentDevice";
|
||||
export * from "./DeviceListenerOtherDevices";
|
||||
export type * from "./DeviceState";
|
||||
@@ -11,7 +11,7 @@ import { ErrorSolidIcon } from "@vector-im/compound-design-tokens/assets/web/ico
|
||||
|
||||
import { _t } from "../languageHandler";
|
||||
import dis from "../dispatcher/dispatcher";
|
||||
import DeviceListener from "../DeviceListener";
|
||||
import { DeviceListener } from "../device-listener";
|
||||
import GenericToast from "../components/views/toasts/GenericToast";
|
||||
import ToastStore from "../stores/ToastStore";
|
||||
import { Action } from "../dispatcher/actions";
|
||||
|
||||
@@ -15,7 +15,7 @@ import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import Modal from "../Modal";
|
||||
import { _t } from "../languageHandler";
|
||||
import DeviceListener from "../DeviceListener";
|
||||
import { DeviceListener, type DeviceState } from "../device-listener";
|
||||
import SetupEncryptionDialog from "../components/views/dialogs/security/SetupEncryptionDialog";
|
||||
import { AccessCancelledError, accessSecretStorage } from "../SecurityManager";
|
||||
import ToastStore, { type IToast } from "../stores/ToastStore";
|
||||
@@ -31,7 +31,6 @@ import ConfirmKeyStorageOffDialog from "../components/views/dialogs/ConfirmKeySt
|
||||
import { MatrixClientPeg } from "../MatrixClientPeg";
|
||||
import { resetKeyBackupAndWait } from "../utils/crypto/resetKeyBackup";
|
||||
import { PosthogAnalytics } from "../PosthogAnalytics";
|
||||
import type DeviceState from "../device-listener/DeviceState";
|
||||
|
||||
const TOAST_KEY = "setupencryption";
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import { ErrorSolidIcon } from "@vector-im/compound-design-tokens/assets/web/ico
|
||||
import { _t } from "../languageHandler";
|
||||
import dis from "../dispatcher/dispatcher";
|
||||
import { MatrixClientPeg } from "../MatrixClientPeg";
|
||||
import DeviceListener from "../DeviceListener";
|
||||
import { DeviceListener } from "../device-listener";
|
||||
import ToastStore from "../stores/ToastStore";
|
||||
import GenericToast from "../components/views/toasts/GenericToast";
|
||||
import { Action } from "../dispatcher/actions";
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
} from "matrix-js-sdk/src/crypto-api";
|
||||
import { type CryptoSessionStateChange } from "@matrix-org/analytics-events/types/typescript/CryptoSessionStateChange";
|
||||
|
||||
import DeviceListener from "../../src/DeviceListener";
|
||||
import { DeviceListener, BACKUP_DISABLED_ACCOUNT_DATA_KEY } from "../../src/device-listener";
|
||||
import { MatrixClientPeg } from "../../src/MatrixClientPeg";
|
||||
import * as SetupEncryptionToast from "../../src/toasts/SetupEncryptionToast";
|
||||
import * as UnverifiedSessionToast from "../../src/toasts/UnverifiedSessionToast";
|
||||
@@ -37,7 +37,6 @@ import { SettingLevel } from "../../src/settings/SettingLevel";
|
||||
import { getMockClientWithEventEmitter, mockPlatformPeg } from "../test-utils";
|
||||
import { isBulkUnverifiedDeviceReminderSnoozed } from "../../src/utils/device/snoozeBulkUnverifiedDeviceReminder";
|
||||
import { PosthogAnalytics } from "../../src/PosthogAnalytics";
|
||||
import { BACKUP_DISABLED_ACCOUNT_DATA_KEY } from "../../src/device-listener/DeviceListenerCurrentDevice";
|
||||
|
||||
jest.mock("../../src/dispatcher/dispatcher", () => ({
|
||||
dispatch: jest.fn(),
|
||||
|
||||
@@ -16,7 +16,7 @@ import { createTestClient, withClientContextRenderOptions } from "../../../../..
|
||||
import { copyPlaintext } from "../../../../../../src/utils/strings";
|
||||
import Modal from "../../../../../../src/Modal";
|
||||
import ErrorDialog from "../../../../../../src/components/views/dialogs/ErrorDialog";
|
||||
import DeviceListener from "../../../../../../src/DeviceListener";
|
||||
import { DeviceListener } from "../../../../../../src/device-listener";
|
||||
|
||||
jest.mock("../../../../../../src/utils/strings", () => ({
|
||||
copyPlaintext: jest.fn(),
|
||||
|
||||
@@ -13,7 +13,7 @@ import { type MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { RecoveryPanelOutOfSync } from "../../../../../../src/components/views/settings/encryption/RecoveryPanelOutOfSync";
|
||||
import { AccessCancelledError, accessSecretStorage } from "../../../../../../src/SecurityManager";
|
||||
import DeviceListener from "../../../../../../src/DeviceListener";
|
||||
import { DeviceListener } from "../../../../../../src/device-listener";
|
||||
import { createTestClient, withClientContextRenderOptions } from "../../../../../test-utils";
|
||||
|
||||
jest.mock("../../../../../../src/SecurityManager", () => {
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
} from "../../../../../../../src/components/views/settings/tabs/user/EncryptionUserSettingsTab";
|
||||
import { createTestClient, withClientContextRenderOptions } from "../../../../../../test-utils";
|
||||
import Modal from "../../../../../../../src/Modal";
|
||||
import DeviceListener from "../../../../../../../src/DeviceListener";
|
||||
import { DeviceListener } from "../../../../../../../src/device-listener";
|
||||
|
||||
describe("<EncryptionUserSettingsTab />", () => {
|
||||
let matrixClient: MatrixClient;
|
||||
|
||||
@@ -17,7 +17,7 @@ import * as SecurityManager from "../../../src/SecurityManager";
|
||||
import ToastContainer from "../../../src/components/structures/ToastContainer";
|
||||
import { showToast } from "../../../src/toasts/SetupEncryptionToast";
|
||||
import dis from "../../../src/dispatcher/dispatcher";
|
||||
import DeviceListener from "../../../src/DeviceListener";
|
||||
import { DeviceListener } from "../../../src/device-listener";
|
||||
import Modal from "../../../src/Modal";
|
||||
import ConfirmKeyStorageOffDialog from "../../../src/components/views/dialogs/ConfirmKeyStorageOffDialog";
|
||||
import SetupEncryptionDialog from "../../../src/components/views/dialogs/security/SetupEncryptionDialog";
|
||||
|
||||
@@ -18,7 +18,7 @@ import { showToast } from "../../../src/toasts/UnverifiedSessionToast";
|
||||
import { filterConsole, flushPromises, stubClient } from "../../test-utils";
|
||||
import ToastContainer from "../../../src/components/structures/ToastContainer";
|
||||
import { Action } from "../../../src/dispatcher/actions";
|
||||
import DeviceListener from "../../../src/DeviceListener";
|
||||
import { DeviceListener } from "../../../src/device-listener";
|
||||
|
||||
describe("UnverifiedSessionToast", () => {
|
||||
const otherDevice: IMyDevice = {
|
||||
|
||||
Reference in New Issue
Block a user