TextBuffer: treat short buffers as a status

This commit is contained in:
He4eT 2021-07-19 17:50:40 +05:00 committed by Alexey
commit d95ee172bb

View file

@ -3,6 +3,9 @@ import { useEffect, useRef, useState } from 'preact/hooks'
import TextMessage from './TextMessage' import TextMessage from './TextMessage'
const isFakeStatus = w =>
w.height < 5
const trimInputPrompt = messages => const trimInputPrompt = messages =>
messages.length < 1 messages.length < 1
? messages ? messages
@ -22,7 +25,7 @@ const parseInbox = (inbox, currentWindow) => {
} }
} }
const { clear, text: inboxMessagesRaw } = const { text: inboxMessagesRaw } =
currentInbox currentInbox
const eol = { style: 'endOfLine' } const eol = { style: 'endOfLine' }
@ -38,7 +41,12 @@ const parseInbox = (inbox, currentWindow) => {
.reduce((acc, x) => .reduce((acc, x) =>
acc.concat(x), []) acc.concat(x), [])
return { clear, incoming } return {
incoming,
clear: isFakeStatus(currentWindow)
? true
: currentInbox.clear
}
} }
export default function ({ inbox, currentWindow }) { export default function ({ inbox, currentWindow }) {
@ -66,10 +74,16 @@ export default function ({ inbox, currentWindow }) {
}, 0) }, 0)
}, [inbox]) }, [inbox])
const classes = [
isFakeStatus(currentWindow)
? 'gridBuffer'
: 'textBuffer',
'buffer'].join(' ')
return ( return (
<section <section
ref={textBufferEl} ref={textBufferEl}
className='buffer textBuffer'> className={classes}>
{messages.map(TextMessage)} {messages.map(TextMessage)}
</section> </section>
) )