forked from mystiq/hydrogen-web
Create tile using tileCreator
This commit is contained in:
parent
54004eef4d
commit
91912bdb8d
3 changed files with 9 additions and 23 deletions
|
@ -22,6 +22,7 @@ export class TextTile extends BaseTextTile {
|
|||
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this._tileCreator = options.tileCreator;
|
||||
this._replyTextTile = null;
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ export class TextTile extends BaseTextTile {
|
|||
if (!this._replyTextTile) {
|
||||
const entry = this._entry.contextEntry;
|
||||
if (entry) {
|
||||
this._replyTextTile = new TextTile(this.childOptions({entry, roomVM: this._roomVM, timeline: this._timeline}));
|
||||
this._replyTextTile = this._tileCreator(entry);
|
||||
}
|
||||
}
|
||||
return this._replyTextTile;
|
||||
|
|
|
@ -28,8 +28,8 @@ import {EncryptionEnabledTile} from "./tiles/EncryptionEnabledTile.js";
|
|||
import {MissingAttachmentTile} from "./tiles/MissingAttachmentTile.js";
|
||||
|
||||
export function tilesCreator(baseOptions) {
|
||||
return function tilesCreator(entry, emitUpdate) {
|
||||
const options = Object.assign({entry, emitUpdate}, baseOptions);
|
||||
const creator = function tilesCreator(entry, emitUpdate) {
|
||||
const options = Object.assign({entry, emitUpdate, tileCreator: creator}, baseOptions);
|
||||
if (entry.isGap) {
|
||||
return new GapTile(options);
|
||||
} else if (entry.isPending && entry.pendingEvent.isMissingAttachments) {
|
||||
|
@ -77,4 +77,5 @@ export function tilesCreator(baseOptions) {
|
|||
}
|
||||
}
|
||||
}
|
||||
return creator;
|
||||
}
|
||||
|
|
|
@ -26,33 +26,17 @@ export class ReplyPreviewView extends TemplateView {
|
|||
while (replyContainer.lastChild) {
|
||||
replyContainer.removeChild(replyContainer.lastChild);
|
||||
}
|
||||
replyContainer.appendChild(vm.isRedacted? this._renderError(vm) : this._renderReplyPreview(vm));
|
||||
replyContainer.appendChild(vm.isRedacted? this._renderRedaction(vm) : this._renderReplyPreview(vm));
|
||||
})
|
||||
return replyContainer;
|
||||
}
|
||||
|
||||
_renderError(vm) {
|
||||
const errorMessage = this._getErrorMessage(vm);
|
||||
const children = [tag.span({ className: "statusMessage" }, errorMessage), tag.br()];
|
||||
let reply;
|
||||
try {
|
||||
reply = this._renderReplyHeader(vm, children);
|
||||
}
|
||||
catch {
|
||||
reply = tag.blockquote(children);
|
||||
}
|
||||
_renderRedaction(vm) {
|
||||
const children = [tag.span({ className: "statusMessage" }, vm.description), tag.br()];
|
||||
const reply = this._renderReplyHeader(vm, children);
|
||||
return reply;
|
||||
}
|
||||
|
||||
_getErrorMessage(vm) {
|
||||
if (vm.isRedacted) {
|
||||
return "This message has been deleted.";
|
||||
}
|
||||
else if (vm.decryptionError) {
|
||||
return vm.decryptionError.message;
|
||||
}
|
||||
}
|
||||
|
||||
_renderReplyPreview(vm) {
|
||||
const reply = this._renderReplyHeader(vm);
|
||||
const body = vm.body;
|
||||
|
|
Loading…
Reference in a new issue