use objects in states

instead of id strings
This commit is contained in:
TreetopFlyer 2022-04-26 10:47:45 -04:00
parent 034067f796
commit d3e7e3152f

24
app.js
View File

@ -51,11 +51,11 @@ const App = props =>
/** @type {Boxcast.StateBinding<Array<Boxcast.Broadcast>>} */
const [ListGet, ListSet] = useState([]);
/** @type {Boxcast.StateBinding<string>} */
const [SelectedGet, SelectedSet] = useState("");
/** @type {Boxcast.StateBinding<Boxcast.Broadcast|null>} */
const [SelectedGet, SelectedSet] = useState(null);
/** @type {Boxcast.StateBinding<string>} */
const [LiveGet, LiveSet] = useState("");
/** @type {Boxcast.StateBinding<Boxcast.Broadcast|null>} */
const [LiveGet, LiveSet] = useState(null);
/** @type {(inList:Array<Boxcast.Broadcast>)=>Array<Boxcast.Broadcast>} */
const SortStart = (inList) => {
@ -105,20 +105,20 @@ const App = props =>
// on new list
useEffect(()=>
{
let live = "";
let live;
for(let i=0; i<ListGet.length; i++)
{
if(ListGet[i].timeframe != "past")
{
live = ListGet[i].id;
live = ListGet[i];
break;
}
}
if(LiveGet != live)
if(LiveGet?.id != live?.id)
{
console.log("new video starting")
}
if(SelectedGet != live)
if(SelectedGet?.id != live?.id)
{
console.log("would you like to switch?");
}
@ -139,7 +139,7 @@ const App = props =>
{
Player.current.loadChannel(props.channel,
{
selectedBroadcastId: SelectedGet,
selectedBroadcastId: SelectedGet?.id,
showTitle: true,
showDescription: true,
showCountdown: true,
@ -164,9 +164,9 @@ const App = props =>
{
item: item,
previous: ListGet[index-1],
priority: item.id == LiveGet,
selected: item.id == SelectedGet,
select: ()=>SelectedSet(item.id)
priority: item.id == LiveGet?.id,
selected: item.id == SelectedGet?.id,
select: ()=>SelectedSet(item)
}
))
}