Skip to content

Commit 4b6277e

Browse files
committed
fix(programa): restore view mode persistence per team feedback
The previous attempt to fix the initial-load 'jump' by ignoring stale localStorage values was too restrictive. The team wants the user's choice to actually persist across visits. New behavior: - First visit (no saved value): default to visual grid - After user picks list: save to localStorage, restore list on next visit - After user picks grid: save to localStorage, restore grid on next visit Legacy users who had 'list' saved from the old default will see a one-time jump from grid → list on their first visit after this change. After that they can click the grid radio to overwrite the saved value and stop the jump. Also cleaned up: - Removed debug console.log statements left over from the filter fix - Fixed a duplicated function body in the inline script that was breaking astro check
1 parent 48cd9ce commit 4b6277e

1 file changed

Lines changed: 12 additions & 20 deletions

File tree

src/components/ProgramaPage.astro

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ const schedule = await getSchedule()
151151
<script is:inline src="https://pretalx.com/pycones-2026/widgets/schedule.js"></script>
152152

153153
<script is:inline>
154-
try {
155-
console.log('[programa] script starting')
156-
} catch (e) {}
157-
158154
;(function () {
159155
// === View toggle (list <-> grid) ===
160156
;(function () {
@@ -184,10 +180,17 @@ const schedule = await getSchedule()
184180

185181
try {
186182
const saved = localStorage.getItem(STORAGE_KEY)
187-
const defaultChecked = document.querySelector('input[name="schedule-view"]:checked')
188-
const defaultValue = defaultChecked ? defaultChecked.value : null
189-
if ((saved === 'list' || saved === 'grid') && saved === defaultValue) {
190-
applyView(saved)
183+
// Persistence rule: the first time the user lands on /programa
184+
// (no saved value, or stored under the old 'list' default from a
185+
// previous design) we show the current default, which is the
186+
// visual grid. From then on, the user's choice wins: a stored
187+
// 'list' or 'grid' is restored on the next visit.
188+
if (saved === 'list' || saved === 'grid') {
189+
const target = document.querySelector(`input[name="schedule-view"][value="${saved}"]`)
190+
if (target) {
191+
target.checked = true
192+
applyView(saved)
193+
}
191194
}
192195
} catch (e) {}
193196
})()
@@ -249,12 +252,7 @@ const schedule = await getSchedule()
249252
function handleFilterClick(e) {
250253
if (e) e.preventDefault()
251254
const btn = document.getElementById('favorites-filter-btn')
252-
if (!btn) {
253-
try {
254-
console.warn('[programa] filter button not in DOM')
255-
} catch (e) {}
256-
return
257-
}
255+
if (!btn) return
258256
const wasPressed = btn.getAttribute('aria-pressed') === 'true'
259257
const nowPressed = !wasPressed
260258
btn.setAttribute('aria-pressed', nowPressed ? 'true' : 'false')
@@ -269,9 +267,6 @@ const schedule = await getSchedule()
269267
: `${btn.dataset.filterOnPrefix}.`
270268
: btn.dataset.filterOffMessage
271269
announce(message)
272-
try {
273-
console.log('[programa] filter toggled, nowPressed=', nowPressed)
274-
} catch (e) {}
275270
}
276271

277272
function bindFilterButton() {
@@ -280,9 +275,6 @@ const schedule = await getSchedule()
280275
if (btn.dataset.bound === '1') return
281276
btn.addEventListener('click', handleFilterClick)
282277
btn.dataset.bound = '1'
283-
try {
284-
console.log('[programa] filter button bound')
285-
} catch (e) {}
286278
}
287279

288280
// Per-session favourite click handler (event delegation)

0 commit comments

Comments
 (0)