fix(feed): a custom date bound applies once its year is a plausible upload year, not per typed digit (E28)

A native date field reports a complete date on every keystroke of its year (0002, 0020, 0202, 2026),
so one typed year refetched the feed four times. The field holds a draft while focused; leaving it
empty clears the bound, leaving it half-typed restores it.
This commit is contained in:
2026-09-25 23:43:26 +02:00
parent 113da76c36
commit ce171fa954
3 changed files with 119 additions and 31 deletions
+12
View File
@@ -61,3 +61,15 @@ export function selectDateChip(
customOpen: false,
};
}
// The first year an upload can have: YouTube opened in 2005.
const FIRST_UPLOAD_YEAR = 2005;
/** Whether a native date field's value is a bound worth filtering by. The field reports a COMPLETE
* date on every keystroke of its year — typing 2026 passes 0002, 0020 and 0202, each a valid date to
* the browser — so applying every value refetched the feed four times for one year (E28). A bound is
* applied once it is a plausible upload day; a half-typed field reports "" and is not one either. */
export function isCommittableDay(s: string): boolean {
const m = /^(\d{4})-\d{2}-\d{2}$/.exec(s);
return !!m && Number(m[1]) >= FIRST_UPLOAD_YEAR;
}