mirror of
https://github.com/He4eT/elseifplayer.git
synced 2026-05-04 17:07:22 +00:00
TextBuffer: treat short buffers as a status
This commit is contained in:
parent
9db390c76c
commit
d95ee172bb
1 changed files with 18 additions and 4 deletions
|
|
@ -3,6 +3,9 @@ import { useEffect, useRef, useState } from 'preact/hooks'
|
|||
|
||||
import TextMessage from './TextMessage'
|
||||
|
||||
const isFakeStatus = w =>
|
||||
w.height < 5
|
||||
|
||||
const trimInputPrompt = messages =>
|
||||
messages.length < 1
|
||||
? messages
|
||||
|
|
@ -22,7 +25,7 @@ const parseInbox = (inbox, currentWindow) => {
|
|||
}
|
||||
}
|
||||
|
||||
const { clear, text: inboxMessagesRaw } =
|
||||
const { text: inboxMessagesRaw } =
|
||||
currentInbox
|
||||
|
||||
const eol = { style: 'endOfLine' }
|
||||
|
|
@ -38,7 +41,12 @@ const parseInbox = (inbox, currentWindow) => {
|
|||
.reduce((acc, x) =>
|
||||
acc.concat(x), [])
|
||||
|
||||
return { clear, incoming }
|
||||
return {
|
||||
incoming,
|
||||
clear: isFakeStatus(currentWindow)
|
||||
? true
|
||||
: currentInbox.clear
|
||||
}
|
||||
}
|
||||
|
||||
export default function ({ inbox, currentWindow }) {
|
||||
|
|
@ -66,10 +74,16 @@ export default function ({ inbox, currentWindow }) {
|
|||
}, 0)
|
||||
}, [inbox])
|
||||
|
||||
const classes = [
|
||||
isFakeStatus(currentWindow)
|
||||
? 'gridBuffer'
|
||||
: 'textBuffer',
|
||||
'buffer'].join(' ')
|
||||
|
||||
return (
|
||||
<section
|
||||
ref={textBufferEl}
|
||||
className='buffer textBuffer'>
|
||||
className={classes}>
|
||||
{messages.map(TextMessage)}
|
||||
</section>
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue