You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-31 15:24:23 +03:00
Misc lint
This commit is contained in:
@ -26,7 +26,7 @@ describe('MatrixEvent', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const clone = a.getSnapshotCopy();
|
const clone = a.toSnapshot();
|
||||||
expect(clone).toBeDefined();
|
expect(clone).toBeDefined();
|
||||||
expect(clone).not.toBe(a);
|
expect(clone).not.toBe(a);
|
||||||
expect(clone.event).not.toBe(a.event);
|
expect(clone.event).not.toBe(a.event);
|
||||||
@ -54,7 +54,7 @@ describe('MatrixEvent', () => {
|
|||||||
expect(a.isEquivalentTo(a)).toBe(true);
|
expect(a.isEquivalentTo(a)).toBe(true);
|
||||||
expect(b.isEquivalentTo(a)).toBe(false);
|
expect(b.isEquivalentTo(a)).toBe(false);
|
||||||
expect(b.isEquivalentTo(b)).toBe(true);
|
expect(b.isEquivalentTo(b)).toBe(true);
|
||||||
expect(a.getSnapshotCopy().isEquivalentTo(a)).toBe(true);
|
expect(a.toSnapshot().isEquivalentTo(a)).toBe(true);
|
||||||
expect(a.getSnapshotCopy().isEquivalentTo(b)).toBe(false);
|
expect(a.toSnapshot().isEquivalentTo(b)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,8 @@ import * as utils from "../../src/utils";
|
|||||||
import {
|
import {
|
||||||
alphabetPad,
|
alphabetPad,
|
||||||
averageBetweenStrings,
|
averageBetweenStrings,
|
||||||
baseToString, deepSortedObjectEntries,
|
baseToString,
|
||||||
|
deepSortedObjectEntries,
|
||||||
DEFAULT_ALPHABET,
|
DEFAULT_ALPHABET,
|
||||||
lexicographicCompare,
|
lexicographicCompare,
|
||||||
nextString,
|
nextString,
|
||||||
|
@ -1148,14 +1148,15 @@ utils.extend(MatrixEvent.prototype, {
|
|||||||
/**
|
/**
|
||||||
* Get a copy/snapshot of this event. The returned copy will be loosely linked
|
* Get a copy/snapshot of this event. The returned copy will be loosely linked
|
||||||
* back to this instance, though will have "frozen" event information. Other
|
* back to this instance, though will have "frozen" event information. Other
|
||||||
* properties may mutate depending on the state of this instance at the time
|
* properties of this MatrixEvent instance will be copied verbatim, which can
|
||||||
* of snapshotting.
|
* mean they are in reference to this instance despite being on the copy too.
|
||||||
|
* Consumers should be wary of using fields which may mutate over time.
|
||||||
*
|
*
|
||||||
* This is meant to be used to snapshot the event details themselves, not the
|
* This is meant to be used to snapshot the event details themselves, not the
|
||||||
* features (such as sender) surrounding the event.
|
* features (such as sender) surrounding the event.
|
||||||
* @returns {MatrixEvent} A snapshot of this event.
|
* @returns {MatrixEvent} A snapshot of this event.
|
||||||
*/
|
*/
|
||||||
getSnapshotCopy() {
|
toSnapshot() {
|
||||||
const ev = new MatrixEvent(JSON.parse(JSON.stringify(this.event)));
|
const ev = new MatrixEvent(JSON.parse(JSON.stringify(this.event)));
|
||||||
for (const [p, v] of Object.entries(this)) {
|
for (const [p, v] of Object.entries(this)) {
|
||||||
if (p !== "event") { // exclude the thing we just cloned
|
if (p !== "event") { // exclude the thing we just cloned
|
||||||
@ -1168,7 +1169,7 @@ utils.extend(MatrixEvent.prototype, {
|
|||||||
/**
|
/**
|
||||||
* Determines if this event is equivalent to the given event. This only checks
|
* Determines if this event is equivalent to the given event. This only checks
|
||||||
* the event object itself, not the other properties of the event. Intended for
|
* the event object itself, not the other properties of the event. Intended for
|
||||||
* use with getSnapshotCopy() to identify events changing.
|
* use with toSnapshot() to identify events changing.
|
||||||
* @param {MatrixEvent} otherEvent The other event to check against.
|
* @param {MatrixEvent} otherEvent The other event to check against.
|
||||||
* @returns {boolean} True if the events are the same, false otherwise.
|
* @returns {boolean} True if the events are the same, false otherwise.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user