Live portal: rename streams (tab double-click, persisted per browser) and name tab groups (header slot, session)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
25
live/src/names.js
Normal file
25
live/src/names.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { create } from './tinyStore.js'
|
||||
|
||||
// Viewer-side labels. Stream names persist in this browser (localStorage, keyed by the MediaMTX path);
|
||||
// group names live for the session (dockview group ids are regenerated on reload).
|
||||
const KEY = 'vg.names'
|
||||
let saved = {}
|
||||
try { saved = JSON.parse(localStorage.getItem(KEY) || '{}') || {} } catch {}
|
||||
|
||||
export const names = create({
|
||||
streams: saved,
|
||||
groups: {},
|
||||
rename(id, value) {
|
||||
const streams = { ...this.streams }
|
||||
if (value) streams[id] = value; else delete streams[id]
|
||||
try { localStorage.setItem(KEY, JSON.stringify(streams)) } catch {}
|
||||
return { streams }
|
||||
},
|
||||
renameGroup(id, value) {
|
||||
const groups = { ...this.groups }
|
||||
if (value) groups[id] = value; else delete groups[id]
|
||||
return { groups }
|
||||
},
|
||||
})
|
||||
|
||||
export const streamLabel = (id, params) => names.get().streams[id] || `${params.user} · ${params.title}`
|
||||
Reference in New Issue
Block a user