Handle unsuccessfully decrypted messages, too.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4301 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-05-17 16:57:43 +00:00
parent e073ebedd1
commit bf9ff088fd

View File

@ -221,7 +221,12 @@ class TfMessageElement extends LitElement {
}
async try_decrypt(content) {
this.decrypted = JSON.parse(await tfrpc.rpc.try_decrypt(this.whoami, content));
let result = await tfrpc.rpc.try_decrypt(this.whoami, content);
if (result) {
this.decrypted = JSON.parse(result);
} else {
this.decrypted = false;
}
}
render() {
@ -442,11 +447,13 @@ class TfMessageElement extends LitElement {
</div>
`);
} else if (typeof(this.message.content) == 'string') {
if (this.decrypted !== undefined) {
if (this.decrypted) {
return small_frame(html`<span>🔓</span><pre>${JSON.stringify(this.decrypted, null, 2)}</pre>`);
} else {
} else if (this.decrypted === undefined) {
this.try_decrypt(content);
return small_frame(html`<span>🔐</span>`);
} else {
return small_frame(html`<span>🔒</span>`);
}
} else {
return small_frame(html`<div><b>type</b>: ${content.type}</div>`);