diff --git a/android/app/src/main/assets/phone/companion.html b/android/app/src/main/assets/phone/companion.html index da02b864..bb005127 100644 --- a/android/app/src/main/assets/phone/companion.html +++ b/android/app/src/main/assets/phone/companion.html @@ -258,6 +258,13 @@ const SLOTS = [['Daytime','06:00 to 17:00'],['Evening','17:00 to 22:00'],['Late' const sameHours = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null); function create() { const c = state.create, d = c.draft; + if (c.done) return `
✓
+
${esc(c.done.name)} is ready on ${c.done.number}
+
${esc(c.done.message || '')}
+ ${c.watching ? `
${esc(c.watching)}
` : ''} + + +
`; const bar = `
${STEPS.map((n, i) => `
${n}
`).join('')}
`; const top = `
${d.number ? 'Edit ' + esc(d.name) : 'Create a channel'}
` + bar; @@ -374,11 +381,27 @@ async function suggestShows() { catch (e) { c.note = e.message; } c.busy = false; render(); } +// A new channel takes a moment to plan its first programmes, so the phone keeps asking until the TV can tune it. +async function watchNew(when) { + const c = state.create; if (!c?.done || c.trying) return; + c.trying = true; c.watching = 'Planning its first programmes…'; render(); + for (let i = 0; i < 30; i++) { + try { + if (when === 'now') await api('/api/tune', {number: c.done.number}); + else await api('/api/queue', {number: c.done.number}); + state.create = null; tab = 'remote'; render(); load('now'); + toast(when === 'now' ? 'On the TV now' : 'Switches when this programme ends'); return; + } catch (e) { if (!/isn't on this TV/.test(e.message)) { c.watching = e.message; break; } } + await new Promise(r => setTimeout(r, 3000)); + } + c.trying = false; if (c.watching === 'Planning its first programmes…') c.watching = "It's still planning. Try again in a minute, or find it in the Guide."; render(); +} async function makeChannel() { const c = state.create, d = c.draft; if (c.busy) return; c.busy = true; render(); try { const r = await api('/api/channels', {number: d.number, name: d.name, description: d.description, style: d.style, hours: d.hours, shows: d.shows, slots: d.style === 'Shaped' ? d.slots : undefined, core: d.style === 'Shaped' ? d.core : undefined}); - state.create = null; toast(r.message || 'Saved'); load('more'); } + // Made: offer to watch it now, or straight after the programme on the TV (Paul, 7 November 2026). + c.done = {number: r.number, name: d.name, message: r.message, edit: !!d.number}; c.busy = false; render(); load('more'); } catch (e) { c.note = e.message; c.busy = false; render(); } } @@ -496,6 +519,8 @@ document.addEventListener('click', e => { if (d.cout) { const dr = state.create.draft; dr.shows = dr.shows.filter(x => x.id !== d.cout); dr.core = dr.core.filter(x => x !== d.cout); delete dr.slots[d.cout]; if (!dr.shows.length) { state.create.step = 1; } render(); return; } if (d.cmake) { makeChannel(); return; } + if (d.cdone) { state.create = null; render(); return; } + if (d.cwatch) { watchNew(d.cwatch); return; } if (d.homedone) { try { localStorage.setItem('orbit.home', '1'); } catch {} closeSheet(); return; } if (d.install) { installAsk?.prompt(); installAsk = null; try { localStorage.setItem('orbit.home', '1'); } catch {} closeSheet(); return; } if (d.home) { openSheet(homeSteps()); return; }