The Plex watch import inserted plex_states via per-row ORM add against a pre-read 'existing' set, which is not safe when the enable call fires more than once while the multi-second import runs (the toggle wasn't disabled during it): overlapping imports raced to INSERT the same (user_id, item_id) rows and all but the first hit a UniqueViolation -> 500 (seen on prod). Rewrite the write path as a chunked PostgreSQL UPSERT (on_conflict_do_update, rows de-duped by item_id) — idempotent and concurrency-safe, Plex still wins on the intersection and Siftlode-only states are untouched. Also disable the Settings toggle (and ignore its onChange) while a sync mutation is pending, so it can't be fired repeatedly; adds a reusable 'disabled' prop to the Switch primitive. |
||
|---|---|---|
| .. | ||
| public | ||
| src | ||
| index.html | ||
| package-lock.json | ||
| package.json | ||
| postcss.config.js | ||
| tailwind.config.js | ||
| tsconfig.json | ||
| vite.config.ts | ||