mirror of
https://github.com/streamwall/streamwall.git
synced 2026-01-29 00:12:49 -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)
|
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) {
|
export async function* pollDataURL(url, intervalSecs) {
|
||||||
const refreshInterval = intervalSecs * 1000
|
const refreshInterval = intervalSecs * 1000
|
||||||
let lastData = []
|
let lastData = []
|
||||||
@@ -31,7 +24,7 @@ export async function* pollDataURL(url, intervalSecs) {
|
|||||||
if (!data.length && lastData.length) {
|
if (!data.length && lastData.length) {
|
||||||
console.warn('using cached stream data')
|
console.warn('using cached stream data')
|
||||||
} else {
|
} else {
|
||||||
yield filterLive(data)
|
yield data
|
||||||
lastData = 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) {
|
function useYDoc(keys) {
|
||||||
const [doc, setDoc] = useState(new Y.Doc())
|
const [doc, setDoc] = useState(new Y.Doc())
|
||||||
const [docValue, setDocValue] = useState()
|
const [docValue, setDocValue] = useState()
|
||||||
@@ -500,10 +518,17 @@ function App({ wsEndpoint, role }) {
|
|||||||
[handleSwapView, focusedInputIdx],
|
[handleSwapView, focusedInputIdx],
|
||||||
)
|
)
|
||||||
|
|
||||||
const normalStreams = streams.filter(
|
const [liveStreams, otherStreams] = filterStreams(streams)
|
||||||
(s) =>
|
function StreamList({ rows }) {
|
||||||
!s.kind || s.kind === 'video' || s.kind === 'audio' || s.kind === 'web',
|
return rows.map((row) => (
|
||||||
)
|
<StreamLine
|
||||||
|
id={row._id}
|
||||||
|
row={row}
|
||||||
|
disabled={!roleCan(role, 'mutate-state-doc')}
|
||||||
|
onClickId={handleClickId}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack flex="1">
|
<Stack flex="1">
|
||||||
@@ -585,18 +610,16 @@ function App({ wsEndpoint, role }) {
|
|||||||
</Stack>
|
</Stack>
|
||||||
<Stack flex="1" scroll={true} minHeight={200}>
|
<Stack flex="1" scroll={true} minHeight={200}>
|
||||||
<StyledDataContainer isConnected={isConnected}>
|
<StyledDataContainer isConnected={isConnected}>
|
||||||
<div>
|
{isConnected ? (
|
||||||
{isConnected
|
<div>
|
||||||
? normalStreams.map((row) => (
|
<h3>Live</h3>
|
||||||
<StreamLine
|
<StreamList rows={liveStreams} />
|
||||||
id={row._id}
|
<h3>Offline / Unknown</h3>
|
||||||
row={row}
|
<StreamList rows={otherStreams} />
|
||||||
disabled={!roleCan(role, 'mutate-state-doc')}
|
</div>
|
||||||
onClickId={handleClickId}
|
) : (
|
||||||
/>
|
<div>loading...</div>
|
||||||
))
|
)}
|
||||||
: 'loading...'}
|
|
||||||
</div>
|
|
||||||
{roleCan(role, 'set-custom-streams') && (
|
{roleCan(role, 'set-custom-streams') && (
|
||||||
<>
|
<>
|
||||||
<h2>Custom Streams</h2>
|
<h2>Custom Streams</h2>
|
||||||
|
|||||||
Reference in New Issue
Block a user