From 4f00566b9f07afcfbb15af3a56ab883265787c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 4 Nov 2022 14:48:42 +0100 Subject: [PATCH] Do not freeze state in `initialiseState()` (#2846) --- src/models/event-timeline.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/models/event-timeline.ts b/src/models/event-timeline.ts index 364462bc8..716512f5a 100644 --- a/src/models/event-timeline.ts +++ b/src/models/event-timeline.ts @@ -153,22 +153,6 @@ export class EventTimeline { throw new Error("Cannot initialise state after events are added"); } - // We previously deep copied events here and used different copies in - // the oldState and state events: this decision seems to date back - // quite a way and was apparently made to fix a bug where modifications - // made to the start state leaked through to the end state. - // This really shouldn't be possible though: the events themselves should - // not change. Duplicating the events uses a lot of extra memory, - // so we now no longer do it. To assert that they really do never change, - // freeze them! Note that we can't do this for events in general: - // although it looks like the only things preventing us are the - // 'status' flag, forwardLooking (which is only set once when adding to the - // timeline) and possibly the sender (which seems like it should never be - // reset but in practice causes a lot of the tests to break). - for (const e of stateEvents) { - Object.freeze(e); - } - this.startState?.setStateEvents(stateEvents, { timelineWasEmpty }); this.endState?.setStateEvents(stateEvents, { timelineWasEmpty }); }