From be236309c52fb6f33bb8bf9441c1ee0405b36685 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Tue, 11 May 2021 10:08:57 +0100 Subject: [PATCH] use arrayFastClone instead of slice --- src/components/structures/TimelinePanel.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index a3c1c56276..5012d91a5f 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -38,6 +38,7 @@ import {haveTileForEvent} from "../views/rooms/EventTile"; import {UIFeature} from "../../settings/UIFeature"; import {objectHasDiff} from "../../utils/objects"; import {replaceableComponent} from "../../utils/replaceableComponent"; +import { arrayFastClone } from "../../utils/arrays"; const PAGINATE_SIZE = 20; const INITIAL_SIZE = 20; @@ -1142,11 +1143,11 @@ class TimelinePanel extends React.Component { _getEvents() { const events = this._timelineWindow.getEvents(); - // `slice` performs a shallow copy of the array + // `arrayFastClone` performs a shallow copy of the array // we want the last event to be decrypted first but displayed last // `reverse` is destructive and unfortunately mutates the "events" array - events - .slice().reverse() + arrayFastClone(events) + .reverse() .forEach(event => { if (event.shouldAttemptDecryption()) { event.attemptDecryption(MatrixClientPeg.get()._crypto);