Skip to content

fix(recipes): don't leak 0 next to private recipe titles#129

Merged
hyldmo merged 1 commit into
mainfrom
hyldmo/recipe-list-zero-render
May 11, 2026
Merged

fix(recipes): don't leak 0 next to private recipe titles#129
hyldmo merged 1 commit into
mainfrom
hyldmo/recipe-list-zero-render

Conversation

@hyldmo
Copy link
Copy Markdown
Owner

@hyldmo hyldmo commented May 11, 2026

Summary

  • recipe.isPublic is an integer column (0 | 1), so {recipe.isPublic && <Globe/>} in RecipeCard rendered the literal 0 next to the recipe name on every private card.
  • Use === 1 so the falsy branch is false (not 0) and React renders nothing.

Test plan

  • Recipe list shows the globe icon on published recipes
  • Private recipes show no stray 0 after the "yours" badge

🤖 Generated with Claude Code

`recipe.isPublic` is an integer column (0|1), so `{recipe.isPublic && <Globe/>}`
rendered a literal "0" next to the recipe name on private cards.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

Preview deployment

URL https://hyldmo-recipe-list-zero-rend.macromaxxing.pages.dev
Branch hyldmo/recipe-list-zero-render
Commit dda9dd4

@hyldmo hyldmo merged commit ed0118b into main May 11, 2026
3 checks passed
@hyldmo hyldmo deleted the hyldmo/recipe-list-zero-render branch May 11, 2026 18:54
hyldmo added a commit that referenced this pull request May 11, 2026
* refactor(db): use Drizzle boolean mode for 0|1 flag columns

Switches `isPublic`, `isDefault`, `isVolume`, `failureFlag`, `batchLookups`,
and `modelFallback` to `integer(..., { mode: 'boolean' })`. The on-disk
representation stays as INTEGER 0/1 — this is purely a TS-layer codec.

Side effect: `{flag && <X/>}` short-circuits to `false` (which React skips)
instead of rendering the literal `0`. Prevents the whole class of bugs that
hit `recipe.isPublic` in #129.

Call sites updated: writes pass true/false directly (no more `? 1 : 0`),
reads compare against booleans, and the API layer drops its `Boolean(...)`
coercion wrappers since the column already returns boolean.

The generated migration is a no-op (`SELECT 1`) — Drizzle wants to recreate
five tables to refresh the schema string, but the actual SQLite column type
is unchanged, so production data needs no rewrite.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* refactor(db): drop redundant boolean coercion at trust boundaries

Zod schemas (`z.boolean()` / `z.boolean().optional()`) already narrow these
inputs to `boolean | undefined` before they reach the handlers, so the `!!`
and `=== true` coercions added in c3abc1b were noise.

- workouts/addSet: `failureFlag: !!input.failureFlag` → pass through
- ingredients/createUnit: same for `isDefault`
- ingredients/updateUnit: drop the explicit `isDefault` override; just spread
  `updates` (the inner `if (updates.isDefault)` already clears siblings)
- WorkoutSessionPage optimistic update: pass `variables.failureFlag` directly
- SetRow: `failureFlag === true` → `failureFlag` (null/undefined fall through
  as falsy, which is what JSX wants anyway)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant