Skip to content

Phase 13: Account sync API for loadout favorites #346

Description

@elfensky

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiAPI endpoint workfeatureThis is a planned new feature

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions