Skip to content

Hide "Næsti hálfleikur" button after advancing to next half#141

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/fix-nasti-halfleikur-button
Draft

Hide "Næsti hálfleikur" button after advancing to next half#141
Copilot wants to merge 4 commits intomasterfrom
copilot/fix-nasti-halfleikur-button

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 4, 2026

After clicking "Næsti hálfleikur", the button remained visible because timeElapsed was set to the half-stop time (e.g., 45 min), keeping the show condition !started && showInjuryTime && timeElapsed != 0 permanently true — making it easy to accidentally skip ahead multiple halves.

Root cause

pauseMatch(true) stored the absolute match clock position in timeElapsed, conflating "where is the clock display" with "how much has elapsed this half". The button visibility relied on timeElapsed != 0 as its signal, which was never reset.

Changes

  • New halfOffset field on Match — stores the absolute start-of-half offset (e.g., 45 min at start of 2nd half). Parsed from Firebase with fallback to 0 for backward compatibility.
  • pauseMatch(true) revised — sets halfOffset = halfStops[0] * 60 * 1000 and resets timeElapsed = 0, rather than accumulating into timeElapsed.
  • Clock formula updatedmilliSecondsElapsed = halfOffset + timeElapsed + (running ? serverTime - started : 0). Clock display is unchanged.
  • isTimeNull updated!started && !timeElapsed && !halfOffset so the clock still shows 45:00 at the start of 2nd half.
  • Button condition tightened — "Næsti hálfleikur" now requires !!match.timeElapsed; countdown button requires !halfOffset in addition to !timeElapsed.
// Before: timeElapsed stayed at 45 min after click → button never hid
newState.timeElapsed = (newState.halfStops[0] ?? 0) * 60 * 1000;

// After: clock position split into offset + per-half elapsed
newState.halfOffset = (newState.halfStops[0] ?? 0) * 60 * 1000;
newState.timeElapsed = 0;  // button condition now false → hidden
Original prompt

This section details on the original issue you should resolve

<issue_title>næsti hálfleikur</issue_title>
<issue_description>when clicking næsti hálfleikur it should be removed until we clicked again</issue_description>

<agent_instructions>basically if the current time is 0 (we have 2 notions of time, time elapsed and time set, on new half we set the time and set elapsed to 0, don't remember if these are the correct terms but thats how it works)</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…to 0 and using halfOffset for clock display

Co-authored-by: sindrig <683742+sindrig@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix næsti hálfleikur button functionality Hide "Næsti hálfleikur" button after advancing to next half Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

næsti hálfleikur

2 participants