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) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
|
this._tileCreator = options.tileCreator;
|
||||||
this._replyTextTile = null;
|
this._replyTextTile = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ export class TextTile extends BaseTextTile {
|
||||||
if (!this._replyTextTile) {
|
if (!this._replyTextTile) {
|
||||||
const entry = this._entry.contextEntry;
|
const entry = this._entry.contextEntry;
|
||||||
if (entry) {
|
if (entry) {
|
||||||
this._replyTextTile = new TextTile(this.childOptions({entry, roomVM: this._roomVM, timeline: this._timeline}));
|
this._replyTextTile = this._tileCreator(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this._replyTextTile;
|
return this._replyTextTile;
|
||||||
|
|
|
@ -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 creator = function tilesCreator(entry, emitUpdate) {
|
||||||
const options = Object.assign({entry, emitUpdate}, baseOptions);
|
const options = Object.assign({entry, emitUpdate, tileCreator: creator}, 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,4 +77,5 @@ export function tilesCreator(baseOptions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return creator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,33 +26,17 @@ export class ReplyPreviewView extends TemplateView {
|
||||||
while (replyContainer.lastChild) {
|
while (replyContainer.lastChild) {
|
||||||
replyContainer.removeChild(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;
|
return replyContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
_renderError(vm) {
|
_renderRedaction(vm) {
|
||||||
const errorMessage = this._getErrorMessage(vm);
|
const children = [tag.span({ className: "statusMessage" }, vm.description), tag.br()];
|
||||||
const children = [tag.span({ className: "statusMessage" }, errorMessage), tag.br()];
|
const reply = this._renderReplyHeader(vm, children);
|
||||||
let reply;
|
|
||||||
try {
|
|
||||||
reply = this._renderReplyHeader(vm, children);
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
reply = tag.blockquote(children);
|
|
||||||
}
|
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
_getErrorMessage(vm) {
|
|
||||||
if (vm.isRedacted) {
|
|
||||||
return "This message has been deleted.";
|
|
||||||
}
|
|
||||||
else if (vm.decryptionError) {
|
|
||||||
return vm.decryptionError.message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_renderReplyPreview(vm) {
|
_renderReplyPreview(vm) {
|
||||||
const reply = this._renderReplyHeader(vm);
|
const reply = this._renderReplyHeader(vm);
|
||||||
const body = vm.body;
|
const body = vm.body;
|
||||||
|
|
Loading…
Reference in a new issue