mirror of
https://github.com/streamwall/streamwall.git
synced 2025-12-06 01:45:37 -05:00
Stop filtering out offline/unknown streams from list
This commit is contained in:
@@ -8,13 +8,6 @@ import chokidar from 'chokidar'
|
||||
|
||||
const sleep = promisify(setTimeout)
|
||||
|
||||
function filterLive(data) {
|
||||
return data.filter(
|
||||
({ kind, status }) =>
|
||||
(kind && kind !== 'video') || status === 'Live' || status === 'Unknown',
|
||||
)
|
||||
}
|
||||
|
||||
export async function* pollDataURL(url, intervalSecs) {
|
||||
const refreshInterval = intervalSecs * 1000
|
||||
let lastData = []
|
||||
@@ -31,7 +24,7 @@ export async function* pollDataURL(url, intervalSecs) {
|
||||
if (!data.length && lastData.length) {
|
||||
console.warn('using cached stream data')
|
||||
} else {
|
||||
yield filterLive(data)
|
||||
yield data
|
||||
lastData = data
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,24 @@ const GlobalStyle = createGlobalStyle`
|
||||
}
|
||||
`
|
||||
|
||||
const normalStreamKinds = new Set(['video', 'audio', 'web'])
|
||||
function filterStreams(streams) {
|
||||
const liveStreams = []
|
||||
const otherStreams = []
|
||||
for (const stream of streams) {
|
||||
const { kind, status } = stream
|
||||
if (kind && !normalStreamKinds.has(kind)) {
|
||||
continue
|
||||
}
|
||||
if ((kind && kind !== 'video') || status === 'Live') {
|
||||
liveStreams.push(stream)
|
||||
} else {
|
||||
otherStreams.push(stream)
|
||||
}
|
||||
}
|
||||
return [liveStreams, otherStreams]
|
||||
}
|
||||
|
||||
function useYDoc(keys) {
|
||||
const [doc, setDoc] = useState(new Y.Doc())
|
||||
const [docValue, setDocValue] = useState()
|
||||
@@ -500,10 +518,17 @@ function App({ wsEndpoint, role }) {
|
||||
[handleSwapView, focusedInputIdx],
|
||||
)
|
||||
|
||||
const normalStreams = streams.filter(
|
||||
(s) =>
|
||||
!s.kind || s.kind === 'video' || s.kind === 'audio' || s.kind === 'web',
|
||||
)
|
||||
const [liveStreams, otherStreams] = filterStreams(streams)
|
||||
function StreamList({ rows }) {
|
||||
return rows.map((row) => (
|
||||
<StreamLine
|
||||
id={row._id}
|
||||
row={row}
|
||||
disabled={!roleCan(role, 'mutate-state-doc')}
|
||||
onClickId={handleClickId}
|
||||
/>
|
||||
))
|
||||
}
|
||||
|
||||
return (
|
||||
<Stack flex="1">
|
||||
@@ -585,18 +610,16 @@ function App({ wsEndpoint, role }) {
|
||||
</Stack>
|
||||
<Stack flex="1" scroll={true} minHeight={200}>
|
||||
<StyledDataContainer isConnected={isConnected}>
|
||||
<div>
|
||||
{isConnected
|
||||
? normalStreams.map((row) => (
|
||||
<StreamLine
|
||||
id={row._id}
|
||||
row={row}
|
||||
disabled={!roleCan(role, 'mutate-state-doc')}
|
||||
onClickId={handleClickId}
|
||||
/>
|
||||
))
|
||||
: 'loading...'}
|
||||
</div>
|
||||
{isConnected ? (
|
||||
<div>
|
||||
<h3>Live</h3>
|
||||
<StreamList rows={liveStreams} />
|
||||
<h3>Offline / Unknown</h3>
|
||||
<StreamList rows={otherStreams} />
|
||||
</div>
|
||||
) : (
|
||||
<div>loading...</div>
|
||||
)}
|
||||
{roleCan(role, 'set-custom-streams') && (
|
||||
<>
|
||||
<h2>Custom Streams</h2>
|
||||
|
||||
Reference in New Issue
Block a user