Instantiate message previewers lazily (#34065)
* fix(room-list): instantiate message previewers lazily Removing the unused SettingsStore import from MessagePreviewStore (when the feature_new_room_list flag is dropped) changed module load order and exposed a latent circular dependency: ReactionEventPreview imports MessagePreviewStore, which eagerly did `new ReactionEventPreview()` at module-eval — so importing ReactionEventPreview first (as its unit test does) hit "ReactionEventPreview is not a constructor". Construct the previewers lazily on first use (cached) instead of at module load, so nothing dereferences a mid-evaluation module. Fixes ReactionEventPreview-test. * refactor: pass MessagePreviewStore to ReactEventPreview
This commit is contained in:
+2
-2
@@ -10,12 +10,12 @@ import { RelationType, Room, RoomMember } from "matrix-js-sdk/src/matrix";
|
||||
import { mocked } from "jest-mock";
|
||||
|
||||
import { mkEvent, stubClient } from "../../../../test-utils";
|
||||
// Import directly from the file to avoid circular dependencies with MessagePreviewStore
|
||||
import { ReactionEventPreview } from "../../../../../src/stores/message-preview/previews/ReactionEventPreview";
|
||||
import { MessagePreviewStore } from "../../../../../src/stores/message-preview";
|
||||
import { MatrixClientPeg } from "../../../../../src/MatrixClientPeg";
|
||||
|
||||
describe("ReactionEventPreview", () => {
|
||||
const preview = new ReactionEventPreview();
|
||||
const preview = new ReactionEventPreview(MessagePreviewStore.instance);
|
||||
const userId = "@user:example.com";
|
||||
const roomId = "!room:example.com";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user