Refactor out magic string

This commit is contained in:
RMidhunSuresh 2021-12-12 21:01:56 +05:30
parent 5c0bbdd4c8
commit 39f68e8c2f

View File

@ -25,6 +25,7 @@ import {getRelation, ANNOTATION_RELATION_TYPE} from "./relations.js";
import {REDACTION_TYPE} from "../common.js"; import {REDACTION_TYPE} from "../common.js";
import {NonPersistedEventEntry} from "./entries/NonPersistedEventEntry.js"; import {NonPersistedEventEntry} from "./entries/NonPersistedEventEntry.js";
import {DecryptionSource} from "../../e2ee/common.js"; import {DecryptionSource} from "../../e2ee/common.js";
import {EVENT_TYPE as MEMBER_EVENT_TYPE} from "../members/RoomMember.js";
export class Timeline { export class Timeline {
constructor({roomId, storage, closeCallback, fragmentIdComparer, pendingEvents, clock, powerLevelsObservable, hsApi}) { constructor({roomId, storage, closeCallback, fragmentIdComparer, pendingEvents, clock, powerLevelsObservable, hsApi}) {
@ -290,7 +291,7 @@ export class Timeline {
async _getEventFromHomeserver(eventId) { async _getEventFromHomeserver(eventId) {
const response = await this._hsApi.context(this._roomId, eventId, 0).response(); const response = await this._hsApi.context(this._roomId, eventId, 0).response();
const sender = response.event.sender; const sender = response.event.sender;
const member = response.state.find(e => e.type === "m.room.member" && e.user_id === sender); const member = response.state.find(e => e.type === MEMBER_EVENT_TYPE && e.user_id === sender);
const entry = { const entry = {
event: response.event, event: response.event,
displayName: member.content.displayname, displayName: member.content.displayname,