Printing tracking for owned copies and deck art, and an outdated-card-data notice
Owned copies can now be pinned to a printing + finish (nonfoil / foil / etched), activating the long-dormant library_card_copies table as groups of identical copies. library_cards.quantity_owned stays authoritative: groups are a subset of it, and the rest are "unspecified". Tracking more copies than are unspecified grows ownership to fit; lowering ownership trims the most recently added groups first. Migration 0006 adds the group quantity, a unique (card, printing, finish) index, and deck_cards.preferred_scryfall_id. A deck slot can show a chosen printing's art, both faces from that printing, falling back to the default when the id no longer resolves. It survives quantity/board changes and is kept by duplicate_deck. UI: the click preview's info tile gets a Printings section when opened from the Library or a deck (copy groups with steppers, "Add a printing…", and "Shown in this deck" with Change…/Default), backed by a printing picker grid. The picker takes Escape in the capture phase so it closes without closing the preview under it. Sync: CardEntry.printings (keyed "<scryfall_id>/<finish>") and DeckCardEntry.printing. Cards now merge field by field with groups per key, so a quantity edit and a printing added on another device both survive; merged groups are clamped deterministically. A document is written as version 2 only once it holds printing data, so older builds and servers refuse it instead of dropping the data and syncing the loss. Decklists: "(SET) NUM", optionally "*F*"/"*E*", round-trips through deck and library export/import. Library export writes a line per group plus one for unspecified copies. reference.db printings gain lang and released_at for picker labels and ordering. When the installed card data lacks any column this build's reference schema has (found by diffing against the schema applied in-memory, so no list to maintain), a notice under the top bar offers Update card data (and Import card data… on phones); "Not now" is remembered until something more goes missing.
This commit is contained in:
32
src/App.tsx
32
src/App.tsx
@@ -342,6 +342,14 @@ export default function App() {
|
||||
// invited exactly what happened: a redundant download click before the
|
||||
// real status had even loaded. Distinguish the two explicitly.
|
||||
const statusLoaded = status !== null;
|
||||
// Card data built by an older version lacks columns this one reads, so
|
||||
// some features quietly stay off until it's updated. "Not now" is
|
||||
// remembered against exactly what's missing: the notice comes back once a
|
||||
// later version adds something more.
|
||||
const missingColumns = status?.reference_missing_columns ?? [];
|
||||
const outdatedKey = missingColumns.join(",");
|
||||
const [dismissedOutdated, setDismissedOutdated] = usePersistedState("card-data-outdated-dismissed", "");
|
||||
const showOutdated = ready && missingColumns.length > 0 && !progress && dismissedOutdated !== outdatedKey;
|
||||
// Mirrors `ready` for the automatic-sync callbacks, which must stay stable
|
||||
// across renders (re-creating them would re-arm the listeners below and fire
|
||||
// a fresh sync every time card data finished loading).
|
||||
@@ -632,6 +640,30 @@ export default function App() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showOutdated && (
|
||||
<div className="outdated-bar" role="status">
|
||||
<span className="outdated-bar-message">
|
||||
Your card data was built by an older version of mtgc, so some newer features stay off until you
|
||||
update it.
|
||||
</span>
|
||||
<span className="outdated-bar-actions">
|
||||
<button className="primary" onClick={updateCardData} disabled={busy}>
|
||||
{ICON_DOWNLOAD}
|
||||
Update card data
|
||||
</button>
|
||||
{/* A full download is heavy on a phone; copying a fresh
|
||||
reference.db over from a desktop is the cheaper route. */}
|
||||
{status?.is_mobile && (
|
||||
<button onClick={importReferenceDb} disabled={busy}>
|
||||
{ICON_OPEN_LIBRARY}
|
||||
Import card data…
|
||||
</button>
|
||||
)}
|
||||
<button onClick={() => setDismissedOutdated(outdatedKey)}>Not now</button>
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="content">
|
||||
{!statusLoaded ? (
|
||||
<div className="empty-state">
|
||||
|
||||
Reference in New Issue
Block a user