You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-09 08:42:50 +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:
@@ -54,7 +54,6 @@ import dis from "../../dispatcher/dispatcher";
|
|||||||
import { Action } from "../../dispatcher/actions";
|
import { Action } from "../../dispatcher/actions";
|
||||||
import Timer from "../../utils/Timer";
|
import Timer from "../../utils/Timer";
|
||||||
import shouldHideEvent from "../../shouldHideEvent";
|
import shouldHideEvent from "../../shouldHideEvent";
|
||||||
import { arrayFastClone } from "../../utils/arrays";
|
|
||||||
import MessagePanel from "./MessagePanel";
|
import MessagePanel from "./MessagePanel";
|
||||||
import { IScrollState } from "./ScrollPanel";
|
import { IScrollState } from "./ScrollPanel";
|
||||||
import { ActionPayload } from "../../dispatcher/payloads";
|
import { ActionPayload } from "../../dispatcher/payloads";
|
||||||
@@ -1754,15 +1753,11 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
|||||||
[...mainEvents],
|
[...mainEvents],
|
||||||
);
|
);
|
||||||
|
|
||||||
// `arrayFastClone` performs a shallow copy of the array
|
// We want the last event to be decrypted first
|
||||||
// we want the last event to be decrypted first but displayed last
|
const client = MatrixClientPeg.safeGet();
|
||||||
// `reverse` is destructive and unfortunately mutates the "events" array
|
for (let i = events.length - 1; i >= 0; --i) {
|
||||||
arrayFastClone(events)
|
client.decryptEventIfNeeded(events[i]);
|
||||||
.reverse()
|
}
|
||||||
.forEach((event) => {
|
|
||||||
const client = MatrixClientPeg.safeGet();
|
|
||||||
client.decryptEventIfNeeded(event);
|
|
||||||
});
|
|
||||||
|
|
||||||
const firstVisibleEventIndex = this.checkForPreJoinUISI(events);
|
const firstVisibleEventIndex = this.checkForPreJoinUISI(events);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user