mirror of
https://github.com/element-hq/element-web
synced 2024-11-26 11:15:53 +03:00
Decrypt events in reverse order without copying the array (#12445)
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
This commit is contained in:
parent
cc7edade21
commit
6dd6a7697c
1 changed files with 5 additions and 10 deletions
|
@ -54,7 +54,6 @@ import dis from "../../dispatcher/dispatcher";
|
|||
import { Action } from "../../dispatcher/actions";
|
||||
import Timer from "../../utils/Timer";
|
||||
import shouldHideEvent from "../../shouldHideEvent";
|
||||
import { arrayFastClone } from "../../utils/arrays";
|
||||
import MessagePanel from "./MessagePanel";
|
||||
import { IScrollState } from "./ScrollPanel";
|
||||
import { ActionPayload } from "../../dispatcher/payloads";
|
||||
|
@ -1754,15 +1753,11 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
|||
[...mainEvents],
|
||||
);
|
||||
|
||||
// `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
|
||||
arrayFastClone(events)
|
||||
.reverse()
|
||||
.forEach((event) => {
|
||||
const client = MatrixClientPeg.safeGet();
|
||||
client.decryptEventIfNeeded(event);
|
||||
});
|
||||
// We want the last event to be decrypted first
|
||||
const client = MatrixClientPeg.safeGet();
|
||||
for (let i = events.length - 1; i >= 0; --i) {
|
||||
client.decryptEventIfNeeded(events[i]);
|
||||
}
|
||||
|
||||
const firstVisibleEventIndex = this.checkForPreJoinUISI(events);
|
||||
|
||||
|
|
Loading…
Reference in a new issue