Files
J621/frontend/src/features/online/hotDefault.ts
T
JakeBreath 3bd5bc73dd Fix the order:hot default: seed the toggle and clear stale defaults
Two bugs made the toggle look broken even though the preference was
stored correctly (JakeBreathild had online_hot_default false):

- The Account card never seeded online_hot_default into its form state,
  so the checkbox always rendered checked via the '?? true' fallback.
  It now starts from the saved value.
- Turning the toggle off did not change Online when the URL still
  carried tags=order:hot (e.g. Ctrl+Shift+R reloading the old URL).
  order:hot on its own is the default, not a deliberate search, so it is
  now removed when the account has the toggle off; 'order:hot canine' or
  any other search is still left untouched. The decision moved into
  hotDefault.ts (set-hot / clear-hot / keep) with the matrix verified in
  Node.
2026-09-17 23:49:19 -05:00

23 lines
778 B
TypeScript

/** The metatag the Online page opens with when the account toggle is on. */
export const HOT_ORDER = "order:hot";
export type HotDefaultAction = "set-hot" | "clear-hot" | "keep";
/**
* Decide what the Online default should do for a given search.
*
* `order:hot` on its own is the default, not a deliberate search: it is
* applied when the toggle is on and removed when the account turns it off
* (so a reload of an old URL follows the new setting). Any other search is
* left untouched.
*/
export function hotDefaultAction(
tags: string,
hotDefaultOn: boolean,
): HotDefaultAction {
const trimmed = tags.trim();
if (trimmed === HOT_ORDER) return hotDefaultOn ? "keep" : "clear-hot";
if (!trimmed) return hotDefaultOn ? "set-hot" : "keep";
return "keep";
}