don't store tilesCreator

This commit is contained in:
RMidhunSuresh 2022-01-14 19:11:40 +05:30
parent d18f4d341c
commit 0af9f10166
3 changed files with 9 additions and 17 deletions

View file

@ -150,7 +150,7 @@ export class TilesCollection extends BaseObservableList {
const tileIdx = this._findTileIdx(entry);
const tile = this._findTileAtIdx(entry, tileIdx);
if (tile) {
const action = tile.updateEntry(entry, params);
const action = tile.updateEntry(entry, params, this._tileCreator);
if (action.shouldReplace) {
const newTile = this._tileCreator(entry);
if (newTile) {

View file

@ -21,7 +21,6 @@ import {getIdentifierColorNumber, avatarInitials, getAvatarHttpUrl} from "../../
export class BaseMessageTile extends SimpleTile {
constructor(options) {
super(options);
this._tilesCreator = options.tilesCreator;
this._date = this._entry.timestamp ? new Date(this._entry.timestamp) : null;
this._isContinuation = false;
this._reactions = null;
@ -116,17 +115,17 @@ export class BaseMessageTile extends SimpleTile {
}
}
updateEntry(entry, param) {
updateEntry(entry, param, tilesCreator) {
const replyEntry = entry.contextEntry;
if (replyEntry && this._replyTile) {
if (replyEntry) {
// this is an update to contextEntry used for replyPreview
const action = this._replyTile.updateEntry(replyEntry);
if (action?.shouldReplace) {
const action = this._replyTile?.updateEntry(replyEntry);
if (action?.shouldReplace || !this._replyTile) {
this.disposeTracked(this._replyTile);
this._replyTile = this._tilesCreator(replyEntry);
this._replyTile = tilesCreator(replyEntry);
}
if(action?.shouldUpdate) {
this._replyTile.emitChange();
this._replyTile?.emitChange();
}
}
const action = super.updateEntry(entry, param);
@ -233,12 +232,6 @@ export class BaseMessageTile extends SimpleTile {
if (!this._entry.contextEventId) {
return null;
}
if (!this._replyTile) {
const entry = this._entry.contextEntry;
if (entry) {
this._replyTile = this.track(this._tilesCreator(entry));
}
}
return this._replyTile;
}
}

View file

@ -28,8 +28,8 @@ import {EncryptionEnabledTile} from "./tiles/EncryptionEnabledTile.js";
import {MissingAttachmentTile} from "./tiles/MissingAttachmentTile.js";
export function tilesCreator(baseOptions) {
const creator = function tilesCreator(entry, emitUpdate) {
const options = Object.assign({entry, emitUpdate, tilesCreator: creator}, baseOptions);
return function tilesCreator(entry, emitUpdate) {
const options = Object.assign({entry, emitUpdate}, baseOptions);
if (entry.isGap) {
return new GapTile(options);
} else if (entry.isPending && entry.pendingEvent.isMissingAttachments) {
@ -77,5 +77,4 @@ export function tilesCreator(baseOptions) {
}
}
}
return creator;
}