also try to create replyTile from ctor just in case update doesn't come

This commit is contained in:
Bruno Windels 2022-01-14 16:12:43 +01:00
parent ad335d5088
commit 5f99c2360c
2 changed files with 14 additions and 8 deletions

View file

@ -28,6 +28,7 @@ export class BaseMessageTile extends SimpleTile {
if (this._entry.annotations || this._entry.pendingAnnotations) { if (this._entry.annotations || this._entry.pendingAnnotations) {
this._updateReactions(); this._updateReactions();
} }
this._updateReplyTileIfNeeded(options.tilesCreator);
} }
get _mediaRepository() { get _mediaRepository() {
@ -116,6 +117,15 @@ export class BaseMessageTile extends SimpleTile {
} }
updateEntry(entry, param, tilesCreator) { updateEntry(entry, param, tilesCreator) {
this._updateReplyTileIfNeeded(tilesCreator);
const action = super.updateEntry(entry, param, tilesCreator);
if (action.shouldUpdate) {
this._updateReactions();
}
return action;
}
_updateReplyTileIfNeeded(tilesCreator) {
const replyEntry = entry.contextEntry; const replyEntry = entry.contextEntry;
if (replyEntry) { if (replyEntry) {
// this is an update to contextEntry used for replyPreview // this is an update to contextEntry used for replyPreview
@ -128,11 +138,6 @@ export class BaseMessageTile extends SimpleTile {
this._replyTile?.emitChange(); this._replyTile?.emitChange();
} }
} }
const action = super.updateEntry(entry, param, tilesCreator);
if (action.shouldUpdate) {
this._updateReactions();
}
return action;
} }
startReply() { startReply() {

View file

@ -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) {
return function tilesCreator(entry, emitUpdate) { const tilesCreator = function tilesCreator(entry, emitUpdate) {
const options = Object.assign({entry, emitUpdate}, baseOptions); const options = Object.assign({entry, emitUpdate, tilesCreator}, 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) {
@ -76,5 +76,6 @@ export function tilesCreator(baseOptions) {
return null; return null;
} }
} }
} };
return tilesCreator;
} }