diff --git a/.eslintrc.js b/.eslintrc.js index f3292ed..1736bef 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,6 +7,11 @@ module.exports = { 'standard', 'standard-preact' ], + overrides: [ + { + files: ['*.jsx', '*.js'] + } + ], parserOptions: { ecmaVersion: 12, sourceType: 'module' @@ -15,7 +20,7 @@ module.exports = { }, settings: { react: { - version: 'latest', - }, + version: 'latest' + } } } diff --git a/src/components/player/TextBuffer.jsx b/src/components/player/TextBuffer.jsx index cded3cf..6f158c9 100644 --- a/src/components/player/TextBuffer.jsx +++ b/src/components/player/TextBuffer.jsx @@ -3,24 +3,27 @@ import { useState, useEffect } from 'preact/hooks' const parseInbox = (inbox, currentWindow) => { const currentInbox = - inbox.find(({id}) => + inbox.find(({ id }) => id === currentWindow.id) - if (!currentInbox) return { - clear: false, - incoming: []} + if (!currentInbox) { + return { + clear: false, + incoming: [] + } + } - const {clear, text: inboxMessagesRaw} = + const { clear, text: inboxMessagesRaw } = currentInbox const incoming = inboxMessagesRaw /* Normalize. */ - .map(({content}) => + .map(({ content }) => content || [{ style: 'emptyLine' }]) /* Flatten. */ .reduce((acc, x) => - acc.concat(x), []) + acc.concat(x), []) /* Collapse empty lines. */ .reduce((acc, x, i, xs) => { if (x.style !== 'emptyLine') return [...acc, x] @@ -31,14 +34,14 @@ const parseInbox = (inbox, currentWindow) => { : [...acc, x] }, []) - return {clear, incoming} + return { clear, incoming } } export default function ({ inbox, currentWindow }) { const [messages, setMessages] = useState([]) useEffect(() => { - const {incoming, clear} = + const { incoming, clear } = parseInbox(inbox, currentWindow) setMessages(clear @@ -48,7 +51,7 @@ export default function ({ inbox, currentWindow }) { return (
- {messages?.map(({text}) => + {messages.map(({ text }) => (
{text}
))}
) diff --git a/src/views/PlayerView.jsx b/src/views/PlayerView.jsx index 32c3c1f..7886df2 100644 --- a/src/views/PlayerView.jsx +++ b/src/views/PlayerView.jsx @@ -5,7 +5,7 @@ import UrlPlayer from '~/src/components/player/UrlPlayer' const decode = encodedUrl => decodeURIComponent(encodedUrl) -export default function ({setTheme, theme, encodedUrl}) { +export default function ({ setTheme, theme, encodedUrl }) { useEffect(() => setTheme(theme), [theme]) const [targetUrl, setTargetUrl] = useState(decode(encodedUrl))