forked from mystiq/hydrogen-web
don't store tilesCreator
This commit is contained in:
parent
d18f4d341c
commit
0af9f10166
3 changed files with 9 additions and 17 deletions
|
@ -150,7 +150,7 @@ export class TilesCollection extends BaseObservableList {
|
||||||
const tileIdx = this._findTileIdx(entry);
|
const tileIdx = this._findTileIdx(entry);
|
||||||
const tile = this._findTileAtIdx(entry, tileIdx);
|
const tile = this._findTileAtIdx(entry, tileIdx);
|
||||||
if (tile) {
|
if (tile) {
|
||||||
const action = tile.updateEntry(entry, params);
|
const action = tile.updateEntry(entry, params, this._tileCreator);
|
||||||
if (action.shouldReplace) {
|
if (action.shouldReplace) {
|
||||||
const newTile = this._tileCreator(entry);
|
const newTile = this._tileCreator(entry);
|
||||||
if (newTile) {
|
if (newTile) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ import {getIdentifierColorNumber, avatarInitials, getAvatarHttpUrl} from "../../
|
||||||
export class BaseMessageTile extends SimpleTile {
|
export class BaseMessageTile extends SimpleTile {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
this._tilesCreator = options.tilesCreator;
|
|
||||||
this._date = this._entry.timestamp ? new Date(this._entry.timestamp) : null;
|
this._date = this._entry.timestamp ? new Date(this._entry.timestamp) : null;
|
||||||
this._isContinuation = false;
|
this._isContinuation = false;
|
||||||
this._reactions = null;
|
this._reactions = null;
|
||||||
|
@ -116,17 +115,17 @@ export class BaseMessageTile extends SimpleTile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateEntry(entry, param) {
|
updateEntry(entry, param, tilesCreator) {
|
||||||
const replyEntry = entry.contextEntry;
|
const replyEntry = entry.contextEntry;
|
||||||
if (replyEntry && this._replyTile) {
|
if (replyEntry) {
|
||||||
// this is an update to contextEntry used for replyPreview
|
// this is an update to contextEntry used for replyPreview
|
||||||
const action = this._replyTile.updateEntry(replyEntry);
|
const action = this._replyTile?.updateEntry(replyEntry);
|
||||||
if (action?.shouldReplace) {
|
if (action?.shouldReplace || !this._replyTile) {
|
||||||
this.disposeTracked(this._replyTile);
|
this.disposeTracked(this._replyTile);
|
||||||
this._replyTile = this._tilesCreator(replyEntry);
|
this._replyTile = tilesCreator(replyEntry);
|
||||||
}
|
}
|
||||||
if(action?.shouldUpdate) {
|
if(action?.shouldUpdate) {
|
||||||
this._replyTile.emitChange();
|
this._replyTile?.emitChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const action = super.updateEntry(entry, param);
|
const action = super.updateEntry(entry, param);
|
||||||
|
@ -233,12 +232,6 @@ export class BaseMessageTile extends SimpleTile {
|
||||||
if (!this._entry.contextEventId) {
|
if (!this._entry.contextEventId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!this._replyTile) {
|
|
||||||
const entry = this._entry.contextEntry;
|
|
||||||
if (entry) {
|
|
||||||
this._replyTile = this.track(this._tilesCreator(entry));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this._replyTile;
|
return this._replyTile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@ import {EncryptionEnabledTile} from "./tiles/EncryptionEnabledTile.js";
|
||||||
import {MissingAttachmentTile} from "./tiles/MissingAttachmentTile.js";
|
import {MissingAttachmentTile} from "./tiles/MissingAttachmentTile.js";
|
||||||
|
|
||||||
export function tilesCreator(baseOptions) {
|
export function tilesCreator(baseOptions) {
|
||||||
const creator = function tilesCreator(entry, emitUpdate) {
|
return function tilesCreator(entry, emitUpdate) {
|
||||||
const options = Object.assign({entry, emitUpdate, tilesCreator: creator}, baseOptions);
|
const options = Object.assign({entry, emitUpdate}, baseOptions);
|
||||||
if (entry.isGap) {
|
if (entry.isGap) {
|
||||||
return new GapTile(options);
|
return new GapTile(options);
|
||||||
} else if (entry.isPending && entry.pendingEvent.isMissingAttachments) {
|
} else if (entry.isPending && entry.pendingEvent.isMissingAttachments) {
|
||||||
|
@ -77,5 +77,4 @@ export function tilesCreator(baseOptions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return creator;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue