mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Render error
This commit is contained in:
parent
545aae31d9
commit
67da746b48
@ -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 New Issue
Block a user