What It Does
Repost someone else’s recipe or post to share it on your profile. Similar to a retweet.
Reposts exist in the database (tables, triggers, counters) and the data layer (types, transforms, RPC responses include repost_count and is_reposted), but the repost button is intentionally hidden in the mobile app UI. The DetailActionBar component has the repost action commented out. The infrastructure is ready — it just needs to be wired up when the feature is enabled.
User Flow
Not currently active in the mobile app — the repost button is hidden in DetailActionBar. The flow below describes the intended behavior when enabled.
User taps repost icon on detail view or card → optimistic UI update → direct Supabase call (supabase.from('recipe_reposts').insert/delete or supabase.from('post_reposts').insert/delete).
The mobile app calls Supabase directly for reposts. Unlike favorites, useToggleRepost uses invalidateQueries on success (rather than pure optimistic updates) because repost state is less latency-sensitive than the heart animation.
Web API Routes (Phase 2)
| Method | Route | Purpose |
|---|
POST | /api/recipes/[id]/repost | Repost a recipe |
DELETE | /api/recipes/[id]/repost | Un-repost a recipe |
POST | /api/posts/[id]/repost | Repost a post |
DELETE | /api/posts/[id]/repost | Un-repost a post |
Database
| Table | Key Columns | Notes |
|---|
recipe_reposts | user_id (FK→profiles), recipe_id (FK→recipes) | Composite PK |
post_reposts | user_id (FK→profiles), post_id (FK→posts) | Composite PK |
RLS Policies
SELECT public, INSERT/DELETE auth.uid() = user_id
Triggers
| Trigger | Table | Events | Function |
|---|
trigger_update_recipe_repost_count | recipe_reposts | INSERT, DELETE | update_recipe_repost_count() |
trigger_update_post_repost_count | post_reposts | INSERT, DELETE | update_post_repost_count() |