Summary
Server actions to sync loadout favorites with the user's account via the existing Settings JSON field.
Parent: #162 | Depends on: #345 (localStorage favorites)
Architecture
Two server actions:
syncLoadoutFavorites(favorites) — overwrites server favorites with client data
getLoadoutFavorites() — returns server favorites
Stores in Settings.settings.loadouts JSON path. Client merges localStorage + server on page load (union by hash, client wins on conflict).
Silently falls back to localStorage when auth is disabled or user not signed in — no error states.
Files
- CREATE
src/features/loadout/actions.mjs — 'use server' actions with auth guard
- CREATE
src/features/loadout/useLoadoutSync.mjs — client hook for merge logic
- MODIFY
src/features/loadout/FavoritesList.jsx
Patterns to Follow
src/db/queries/account.mjs for auth guard pattern
tryCatch wrapper for all Prisma calls
- No new Prisma migration needed (Settings model with Json column already exists)
Size: M
Summary
Server actions to sync loadout favorites with the user's account via the existing Settings JSON field.
Parent: #162 | Depends on: #345 (localStorage favorites)
Architecture
Two server actions:
syncLoadoutFavorites(favorites)— overwrites server favorites with client datagetLoadoutFavorites()— returns server favoritesStores in
Settings.settings.loadoutsJSON path. Client merges localStorage + server on page load (union by hash, client wins on conflict).Silently falls back to localStorage when auth is disabled or user not signed in — no error states.
Files
src/features/loadout/actions.mjs—'use server'actions with auth guardsrc/features/loadout/useLoadoutSync.mjs— client hook for merge logicsrc/features/loadout/FavoritesList.jsxPatterns to Follow
src/db/queries/account.mjsfor auth guard patterntryCatchwrapper for all Prisma callsSize: M