Phone remote: status pushes rebuild the list every 2 s, swallowing taps and overwriting typed input #8
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
renderChannels()runs on everystatusbroadcast — roughly every two seconds while something is playing — and it does three expensive/destructive things:Full DOM rebuild.
list.innerHTML = ''followed by a fresh fragment (index.html:520). If a broadcast lands betweentouchstartandtouchend, the tapped button is removed before the browser can synthesize theclick, so the tap is silently dropped. Reproducible any time someone browses channels while playback runs — exactly when it matters.Overwrites what the user is typing.
if (state.playlistUrl) $('playlist-input').value = state.playlistUrl(index.html:522) fires regardless of whether the setup panel is open. Typing a new M3U URL while the TV plays is effectively impossible: keystrokes are replaced every two seconds.O(n) lookup per row.
state.channels.indexOf(c)inside the render loop (index.html:467) scans the whole array for each rendered row. With hundreds of channels that is hundreds of thousands of comparisons every tick, adding jank to the same interaction.Suggested fix
forEach((c, i) => …)) instead ofindexOfFound by multi-agent code review; verified against current
app/src/main/assets/remote/index.html.Fixed in
dd612fc, shipped in v0.9.0. All three parts:renderChannelsIfChanged(), which compares a signature (channel count, search term, favourites filter, favourite ids, currently playing channel) and returns early when nothing changed. A tap can no longer be swallowed by a rebuild that happens between touchstart and touchend.document.activeElement, so typing a URL while the TV plays works.indexOfin the render loop. Channels carry a_idxassigned once when the list arrives, so each row is O(1) instead of scanning the whole array.Also picked up along the way: an empty search result now shows "Keine Sender gefunden." (and "Keine Favoriten — Stern auf einem Sender antippen." in the favourites view) instead of rendering a blank list that looks broken.