From 23714c7e7f0dcedc5731a73191d95589b19b9c0d Mon Sep 17 00:00:00 2001 From: He4eT Date: Sun, 28 Feb 2021 20:17:13 +0500 Subject: [PATCH] Use inline tags for messages --- src/components/player/TextBuffer.jsx | 17 ++++++----------- src/components/player/TextMessage.jsx | 18 ++++++++---------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/components/player/TextBuffer.jsx b/src/components/player/TextBuffer.jsx index ca52f32..46541c2 100644 --- a/src/components/player/TextBuffer.jsx +++ b/src/components/player/TextBuffer.jsx @@ -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 } } diff --git a/src/components/player/TextMessage.jsx b/src/components/player/TextMessage.jsx index ef93625..569700a 100644 --- a/src/components/player/TextMessage.jsx +++ b/src/components/player/TextMessage.jsx @@ -1,16 +1,14 @@ import { h } from 'preact' export default function ({ style, text }) { - const defaultContent = ({text}) + const defaultContent = ( + + {text} + ) - const content = ({ - emptyLine: (
), - subheader: ({text}) + return ({ + input: (> {text}), + subheader: ({text}), + endOfLine: (
) })[style] || defaultContent - - return ( -
- {content} -
- ) }