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:
parent
e073ebedd1
commit
bf9ff088fd
@ -221,7 +221,12 @@ class TfMessageElement extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async try_decrypt(content) {
|
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() {
|
render() {
|
||||||
@ -442,11 +447,13 @@ class TfMessageElement extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
`);
|
`);
|
||||||
} else if (typeof(this.message.content) == 'string') {
|
} 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>`);
|
return small_frame(html`<span>🔓</span><pre>${JSON.stringify(this.decrypted, null, 2)}</pre>`);
|
||||||
|
} else if (this.decrypted === undefined) {
|
||||||
|
this.try_decrypt(content);
|
||||||
|
return small_frame(html`<span>🔐</span>`);
|
||||||
} else {
|
} else {
|
||||||
this.try_decrypt(content);
|
return small_frame(html`<span>🔒</span>`);
|
||||||
return small_frame(html`<span>🔐</span>`);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return small_frame(html`<div><b>type</b>: ${content.type}</div>`);
|
return small_frame(html`<div><b>type</b>: ${content.type}</div>`);
|
||||||
|
Loading…
Reference in New Issue
Block a user