Use inline tags for messages

This commit is contained in:
He4eT 2021-02-28 20:17:13 +05:00
commit 23714c7e7f
2 changed files with 14 additions and 21 deletions

View file

@ -25,23 +25,18 @@ const parseInbox = (inbox, currentWindow) => {
const { clear, text: inboxMessagesRaw } =
currentInbox
const incoming = trimImputPrompt(
const eol = { style: 'endOfLine' }
const incoming =
inboxMessagesRaw
/* Normalize. */
.map(({ content }) =>
content || [{ style: 'emptyLine' }])
content
? [...trimImputPrompt(content), eol]
: [eol])
/* Flatten. */
.reduce((acc, x) =>
acc.concat(x), [])
/* Collapse empty lines. */
.reduce((acc, x, i, xs) => {
if (x.style !== 'emptyLine') return [...acc, x]
const prev = xs[i - 1] || {}
return prev.style === 'emptyLine'
? acc
: [...acc, x]
}, []))
return { clear, incoming }
}