forked from mystiq/hydrogen-web
Render error
This commit is contained in:
parent
545aae31d9
commit
67da746b48
2 changed files with 34 additions and 14 deletions
|
@ -73,9 +73,27 @@ 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 = new ReplyPreviewTile(this.childOptions({entry, roomVM: this._roomVM, timeline: this._timeline}));
|
||||
}
|
||||
}
|
||||
return this._replyTextTile;
|
||||
}
|
||||
}
|
||||
|
||||
class ReplyPreviewTile extends TextTile {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
get isRedacted() {
|
||||
return this._entry.isRedacted;
|
||||
}
|
||||
|
||||
get decryptionError() {
|
||||
return !!this._entry.decryptionError;
|
||||
}
|
||||
|
||||
get error() {
|
||||
return this.isRedacted || this.decryptionError;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,23 +31,25 @@ export class ReplyPreviewView extends TemplateView {
|
|||
return replyContainer;
|
||||
}
|
||||
|
||||
_renderError({ error, avatar, senderName }) {
|
||||
const errorMessage = this._getErrorMessage(error);
|
||||
_renderError(vm) {
|
||||
const errorMessage = this._getErrorMessage(vm);
|
||||
const children = [tag.span({ className: "statusMessage" }, errorMessage), tag.br()];
|
||||
const reply = avatar && senderName ? this._renderReplyHeader(avatar, senderName, children) :
|
||||
tag.blockquote(children);
|
||||
let reply;
|
||||
try {
|
||||
reply = this._renderReplyHeader(vm, children);
|
||||
}
|
||||
catch {
|
||||
reply = tag.blockquote(children);
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
_getErrorMessage(error) {
|
||||
switch (error.name) {
|
||||
case "ContextEntryNotFound":
|
||||
case "MissingBody":
|
||||
return "This message could not be fetched.";
|
||||
case "MessageRedacted":
|
||||
return "This message has been deleted.";
|
||||
default:
|
||||
return error.message;
|
||||
_getErrorMessage(vm) {
|
||||
if (vm.isRedacted) {
|
||||
return "This message has been deleted.";
|
||||
}
|
||||
else if (vm.decryptionError) {
|
||||
return "This message could not be decrypted."
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue