mirror of
https://github.com/streamwall/streamwall.git
synced 2026-01-30 00:42:48 -05:00
Persist custom stream ids by URL like other streams
This makes it possible to edit a custom stream label in place without changing the id and causing it to be removed from the wall.
This commit is contained in:
@@ -119,12 +119,10 @@ export class StreamIDGenerator {
|
|||||||
|
|
||||||
process(streams) {
|
process(streams) {
|
||||||
const { idMap, idSet } = this
|
const { idMap, idSet } = this
|
||||||
const localIdMap = new Map(idMap)
|
|
||||||
const localIdSet = new Set(idSet)
|
|
||||||
|
|
||||||
for (const stream of streams) {
|
for (const stream of streams) {
|
||||||
const { link, source, label, _dataSource } = stream
|
const { link, source, label } = stream
|
||||||
if (!localIdMap.has(link)) {
|
if (!idMap.has(link)) {
|
||||||
let counter = 0
|
let counter = 0
|
||||||
let newId
|
let newId
|
||||||
const idBase = source || label || link
|
const idBase = source || label || link
|
||||||
@@ -141,20 +139,13 @@ export class StreamIDGenerator {
|
|||||||
const counterPart = counter === 0 && textPart ? '' : counter
|
const counterPart = counter === 0 && textPart ? '' : counter
|
||||||
newId = `${textPart}${counterPart}`
|
newId = `${textPart}${counterPart}`
|
||||||
counter++
|
counter++
|
||||||
} while (localIdSet.has(newId))
|
} while (idSet.has(newId))
|
||||||
|
|
||||||
localIdMap.set(link, newId)
|
idMap.set(link, newId)
|
||||||
localIdSet.add(newId)
|
idSet.add(newId)
|
||||||
|
|
||||||
// Custom stream ids are not persisted so that editing them doesn't create a bunch of unused ids.
|
|
||||||
const persistId = _dataSource !== 'custom'
|
|
||||||
if (persistId) {
|
|
||||||
idMap.set(link, newId)
|
|
||||||
idSet.add(newId)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stream._id = localIdMap.get(link)
|
stream._id = idMap.get(link)
|
||||||
}
|
}
|
||||||
return streams
|
return streams
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user