mirror of
https://github.com/streamwall/streamwall.git
synced 2026-01-24 22:22:50 -05:00
Fix options update for multiple views with same URL
This commit is contained in:
@@ -30,7 +30,6 @@ export default class StreamWindow extends EventEmitter {
|
||||
this.backgroundView = null
|
||||
this.overlayView = null
|
||||
this.views = new Map()
|
||||
this.viewsByURL = new Map()
|
||||
this.viewActions = null
|
||||
}
|
||||
|
||||
@@ -253,7 +252,6 @@ export default class StreamWindow extends EventEmitter {
|
||||
}
|
||||
|
||||
const newViews = new Map()
|
||||
const newViewsByURL = new Map()
|
||||
for (const { box, view } of viewsToDisplay) {
|
||||
const { content, x, y, w, h, spaces } = box
|
||||
const pos = {
|
||||
@@ -267,7 +265,6 @@ export default class StreamWindow extends EventEmitter {
|
||||
view.send({ type: 'OPTIONS', options: getDisplayOptions(stream) })
|
||||
view.send({ type: 'DISPLAY', pos, content })
|
||||
newViews.set(view.state.context.id, view)
|
||||
newViewsByURL.set(content.url, view)
|
||||
}
|
||||
for (const view of unusedViews) {
|
||||
const browserView = view.state.context.view
|
||||
@@ -275,7 +272,6 @@ export default class StreamWindow extends EventEmitter {
|
||||
browserView.destroy()
|
||||
}
|
||||
this.views = newViews
|
||||
this.viewsByURL = newViewsByURL
|
||||
this.emitState()
|
||||
}
|
||||
|
||||
@@ -324,12 +320,15 @@ export default class StreamWindow extends EventEmitter {
|
||||
|
||||
onState(state) {
|
||||
this.send('state', state)
|
||||
for (const stream of state.streams) {
|
||||
const { link } = stream
|
||||
this.viewsByURL.get(link)?.send?.({
|
||||
type: 'OPTIONS',
|
||||
options: getDisplayOptions(stream),
|
||||
})
|
||||
for (const view of this.views.values()) {
|
||||
const { url } = view.state.context.content
|
||||
const stream = state.streams.byURL.get(url)
|
||||
if (stream) {
|
||||
view.send({
|
||||
type: 'OPTIONS',
|
||||
options: getDisplayOptions(stream),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,10 @@ export async function* combineDataSources(dataSources) {
|
||||
dataByURL.set(data.link, { ...existing, ...data })
|
||||
}
|
||||
}
|
||||
yield [...dataByURL.values()]
|
||||
const streams = [...dataByURL.values()]
|
||||
// Retain the index to speed up local lookups
|
||||
streams.byURL = dataByURL
|
||||
yield streams
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user