Simplify rich text on-wire format

This commit is contained in:
oxalica 2024-08-30 13:04:57 -04:00
parent c492bb2537
commit 370722731b
5 changed files with 49 additions and 73 deletions

View file

@ -122,8 +122,8 @@ async function showChatMsg(chat) {
function richTextToHtml(richText) {
let ret = ''
for (let [text, attrs] of richText) {
if (attrs === undefined) attrs = {};
for (let e of richText) {
const [text, attrs] = typeof e === 'string' ? [e, {}] : e;
// Incomplete cases.
const tags = [
[attrs.b, 'b'],
@ -241,7 +241,7 @@ async function postChat(text) {
if (text.startsWith('[')) {
richText = JSON.parse(text);
} else {
richText = [[text]];
richText = [text];
}
const signedPayload = await signData({
typ: 'chat',