mirror of
https://github.com/streamwall/streamwall.git
synced 2026-01-24 22:22:50 -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) {
|
||||
const { idMap, idSet } = this
|
||||
const localIdMap = new Map(idMap)
|
||||
const localIdSet = new Set(idSet)
|
||||
|
||||
for (const stream of streams) {
|
||||
const { link, source, label, _dataSource } = stream
|
||||
if (!localIdMap.has(link)) {
|
||||
const { link, source, label } = stream
|
||||
if (!idMap.has(link)) {
|
||||
let counter = 0
|
||||
let newId
|
||||
const idBase = source || label || link
|
||||
@@ -141,20 +139,13 @@ export class StreamIDGenerator {
|
||||
const counterPart = counter === 0 && textPart ? '' : counter
|
||||
newId = `${textPart}${counterPart}`
|
||||
counter++
|
||||
} while (localIdSet.has(newId))
|
||||
} while (idSet.has(newId))
|
||||
|
||||
localIdMap.set(link, newId)
|
||||
localIdSet.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)
|
||||
}
|
||||
idMap.set(link, newId)
|
||||
idSet.add(newId)
|
||||
}
|
||||
|
||||
stream._id = localIdMap.get(link)
|
||||
stream._id = idMap.get(link)
|
||||
}
|
||||
return streams
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user