Skip to content

Sort swipe navigation events chronologically by start time#64

Merged
ProLoser merged 2 commits into
mainfrom
copilot/fix-swipe-event-order
Mar 19, 2026
Merged

Sort swipe navigation events chronologically by start time#64
ProLoser merged 2 commits into
mainfrom
copilot/fix-swipe-event-order

Conversation

Copilot AI commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Swiping left/right through the floating event card navigated events in arbitrary (data source) order rather than chronological order.

Changes

  • map.js — Sort visibleEventsList by parsed start datetime when it's (re)built on each filter update, so left = earlier, right = later
  • Uses a Schwartzian transform (map → sort → map) to parse each event's start timestamp once rather than on every comparator call
  • Events with missing/unparseable date_text or time sort to the end (Infinity) instead of producing NaN-driven random ordering
// Before
visibleEventsList = window.events.get()?.filter(e => e.visible && e.title && e.geometry) || [];

// After
const getEventStartTime = event => {
  if (!event.date_text || !event.time) return Infinity;
  const timestamp = new Date(`${event.date_text} ${event.time.split(' to ')[0]}`).getTime();
  return isNaN(timestamp) ? Infinity : timestamp;
};
visibleEventsList = (window.events.get()?.filter(e => e.visible && e.title && e.geometry) || [])
  .map(event => ({ event, startTime: getEventStartTime(event) }))
  .sort((a, b) => a.startTime - b.startTime)
  .map(({ event }) => event);

Screenshot

UI screenshot

Original prompt

swiping left and right. should move through events based on start time with earlier times being to the left and later start times being to the right. At this moment it looks like the swipe gesture order of events is random


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Co-authored-by: ProLoser <67395+ProLoser@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix swipe gesture order of events by start time Sort swipe navigation events chronologically by start time Mar 18, 2026
Copilot AI requested a review from ProLoser March 18, 2026 23:03
@github-actions

github-actions Bot commented Mar 19, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-03-19 06:39 UTC

@ProLoser
ProLoser marked this pull request as ready for review March 19, 2026 06:38
@ProLoser
ProLoser merged commit 5489023 into main Mar 19, 2026
1 check passed
@ProLoser
ProLoser deleted the copilot/fix-swipe-event-order branch March 19, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants