@sensiblestats/widget-react 0.48.1 → 0.48.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @sensiblestats/widget-react
2
2
 
3
+ ## 0.48.3
4
+
5
+ ### Patch Changes
6
+
7
+ - A finished match now leaves the Today tab instead of showing an FT badge. The schedule endpoint already excludes terminal matches, but a cached schedule kept them on screen for the rest of the session.
8
+
9
+ ## 0.48.2
10
+
11
+ ### Patch Changes
12
+
13
+ - A match that finished more than three and a half hours ago now shows FT and its score instead of its kickoff time and a dash. The Today tab stopped asking about a match once a fixed window after kickoff elapsed, so on a cold load the earliest of the day's matches never had a state at all.
14
+
3
15
  ## 0.48.1
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -129,7 +129,6 @@ var STRINGS = {
129
129
  tabToday: "Today",
130
130
  sectionLive: "Live",
131
131
  halfTime: "HT",
132
- fullTime: "FT",
133
132
  staleStates: "Live scores can't be updated \u2014 showing the last known state."
134
133
  },
135
134
  tr: {
@@ -208,7 +207,6 @@ var STRINGS = {
208
207
  tabToday: "Bug\xFCn",
209
208
  sectionLive: "Canl\u0131",
210
209
  halfTime: "\u0130Y",
211
- fullTime: "MS",
212
210
  staleStates: "Canl\u0131 skorlar g\xFCncellenemiyor \u2014 son bilinen durum g\xF6steriliyor."
213
211
  }
214
212
  };
@@ -288,7 +286,6 @@ function normalizeUi(cfg) {
288
286
  tabToday: strings.tabToday,
289
287
  sectionLive: strings.sectionLive,
290
288
  halfTime: strings.halfTime,
291
- fullTime: strings.fullTime,
292
289
  staleStates: strings.staleStates,
293
290
  pinLabel: strings.pinLabel,
294
291
  unpinLabel: strings.unpinLabel,
@@ -1535,14 +1532,15 @@ function writeSchedule(operatorId, localDate, payload, nowMs) {
1535
1532
  }
1536
1533
 
1537
1534
  // src/dueSet.ts
1538
- var WINDOW_MS = 3.5 * 36e5;
1535
+ var TERMINAL_PHASES = /* @__PURE__ */ new Set(["fullTime", "postponed"]);
1539
1536
  function dueMatchIds(groups, states, nowMs) {
1540
1537
  const due = /* @__PURE__ */ new Set();
1541
1538
  for (const group of groups) {
1542
1539
  for (const match of group.matches) {
1543
- const sinceKickoff = nowMs - match.kickoffUnix * 1e3;
1544
- if (sinceKickoff >= 0 && sinceKickoff <= WINDOW_MS) due.add(match.matchId);
1545
- if (states[match.matchId]?.phase === "live") due.add(match.matchId);
1540
+ if (nowMs - match.kickoffUnix * 1e3 < 0) continue;
1541
+ const phase = states[match.matchId]?.phase;
1542
+ if (phase !== void 0 && TERMINAL_PHASES.has(phase)) continue;
1543
+ due.add(match.matchId);
1546
1544
  }
1547
1545
  }
1548
1546
  return [...due];
@@ -3745,10 +3743,7 @@ function FixtureRow({ match, state, stale, ui, monitor }) {
3745
3743
  const isLive = state?.phase === "live" && !stale;
3746
3744
  const hasScore = (state?.phase === "live" || state?.phase === "fullTime") && typeof state.homeScore === "number" && typeof state.awayScore === "number";
3747
3745
  const ticked = state?.phase === "live" ? state.minuteLabel ?? null : null;
3748
- const isFinished = state?.phase === "fullTime";
3749
- const when = state?.isHalfTime && !stale ? ui.halfTime : isLive ? ticked ?? "\u2014" : state?.phase === "live" ? "\u2014" : isFinished ? ui.fullTime : kickoffLabel(match.kickoffUnix);
3750
- const pin = { kind: "match", matchId: match.matchId };
3751
- const showPin = !isFinished || monitor.isPinned(pinKey(pin));
3746
+ const when = state?.isHalfTime && !stale ? ui.halfTime : isLive ? ticked ?? "\u2014" : state?.phase === "live" ? "\u2014" : kickoffLabel(match.kickoffUnix);
3752
3747
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: isLive || state?.isHalfTime ? "ss-w-drow ss-w-drow--live" : "ss-w-drow", children: [
3753
3748
  /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: isLive || state?.isHalfTime ? "ss-w-drow-when ss-w-drow-when--live" : "ss-w-drow-when", children: when }),
3754
3749
  /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "ss-w-drow-fx", children: [
@@ -3756,7 +3751,7 @@ function FixtureRow({ match, state, stale, ui, monitor }) {
3756
3751
  /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: hasScore ? "ss-w-drow-sc" : "ss-w-drow-sc ss-w-drow-sc--idle", children: hasScore ? `${state.homeScore}\u2013${state.awayScore}` : "\u2013" }),
3757
3752
  /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Side, { name: match.awayTeamName, crest: match.awayTeamImagePath })
3758
3753
  ] }),
3759
- showPin ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(PinToggle, { ui, monitor, pin }) : null
3754
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(PinToggle, { ui, monitor, pin: { kind: "match", matchId: match.matchId } })
3760
3755
  ] });
3761
3756
  }
3762
3757
 
@@ -3764,6 +3759,9 @@ function FixtureRow({ match, state, stale, ui, monitor }) {
3764
3759
  function isTreatedLive(state, pollStale) {
3765
3760
  return state?.phase === "live" && !pollStale;
3766
3761
  }
3762
+ function isFinished(state) {
3763
+ return state?.phase === "fullTime";
3764
+ }
3767
3765
 
3768
3766
  // src/components/CompetitionGroup.tsx
3769
3767
  var import_jsx_runtime50 = require("react/jsx-runtime");
@@ -3795,8 +3793,9 @@ function CompetitionGroup({ group, open, onToggle, states, stale, ui, monitor, d
3795
3793
  var import_jsx_runtime51 = require("react/jsx-runtime");
3796
3794
  function TodayPanel({ discovery, ui, monitor }) {
3797
3795
  const { groups, states, stale, expanded, toggleGroup } = discovery;
3798
- const liveRows = stale ? [] : groups.flatMap((group) => group.matches.filter((m) => isTreatedLive(states[m.matchId], stale)).map((match) => ({ match, rank: group.rank }))).sort((a, b) => a.rank - b.rank);
3799
- const nameCounts = groups.reduce((acc, g) => {
3796
+ const visibleGroups = groups.map((group) => ({ ...group, matches: group.matches.filter((m) => !isFinished(states[m.matchId])) })).filter((group) => group.matches.length > 0);
3797
+ const liveRows = stale ? [] : visibleGroups.flatMap((group) => group.matches.filter((m) => isTreatedLive(states[m.matchId], stale)).map((match) => ({ match, rank: group.rank }))).sort((a, b) => a.rank - b.rank);
3798
+ const nameCounts = visibleGroups.reduce((acc, g) => {
3800
3799
  acc[g.competitionName] = (acc[g.competitionName] ?? 0) + 1;
3801
3800
  return acc;
3802
3801
  }, {});
@@ -3819,7 +3818,7 @@ function TodayPanel({ discovery, ui, monitor }) {
3819
3818
  match.matchId
3820
3819
  )) })
3821
3820
  ] }),
3822
- groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
3821
+ visibleGroups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
3823
3822
  CompetitionGroup,
3824
3823
  {
3825
3824
  group,