fix(shopping): filter out __inactive__ sentinel rows on relay

The old single-list clearRemote wrote a dummy row with card_uid
'__inactive__' instead of deleting. After the multi-list migration
that row still exists alongside real lists, causing every list to
appear twice on the phone — once as "all done" (the empty sentinel)
and once with actual items. Filter it out in shoppingLoadAll and
delete it on bootstrap so it doesn't linger.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
thandClaude Opus 4.6 committed 2026-04-16 17:31:32 +02:00
1 parent be7eb1523e
commit 59be08a8f8
2 files changed
+6 -1

No files matched your search

+2
View File
@@ -271,6 +271,8 @@ if (count($shoppingPk) === 1) {
} elseif (!in_array('position', $shoppingColNames)) { } elseif (!in_array('position', $shoppingColNames)) {
$db->exec('ALTER TABLE shopping_state ADD COLUMN position INTEGER NOT NULL DEFAULT 0'); $db->exec('ALTER TABLE shopping_state ADD COLUMN position INTEGER NOT NULL DEFAULT 0');
} }
// Clean up __inactive__ sentinel rows from the old single-list era.
$db->exec("DELETE FROM shopping_state WHERE card_uid = '__inactive__'");
// Sync-event notifications: replaces the old bot-chat mechanism. When a // Sync-event notifications: replaces the old bot-chat mechanism. When a
// client syncs a card they received, they POST here; the sender polls // client syncs a card they received, they POST here; the sender polls
+4 -1
View File
@@ -14,7 +14,10 @@ $clientTenant = $clientTenant ?? authClient($db);
$tenant = $sessionTenant ?: $clientTenant; $tenant = $sessionTenant ?: $clientTenant;
function shoppingLoadAll(PDO $db, int $tenantId): array { function shoppingLoadAll(PDO $db, int $tenantId): array {
$stmt = $db->prepare('SELECT card_uid, title, body, position, updated_at_client, updated_at_server FROM shopping_state WHERE tenant_id = :t ORDER BY position, title'); // Exclude __inactive__ sentinel rows left over from the old
// single-list era (clearRemote used to write a dummy row instead
// of deleting).
$stmt = $db->prepare("SELECT card_uid, title, body, position, updated_at_client, updated_at_server FROM shopping_state WHERE tenant_id = :t AND card_uid != '__inactive__' ORDER BY position, title");
$stmt->execute(['t' => $tenantId]); $stmt->execute(['t' => $tenantId]);
return $stmt->fetchAll() ?: []; return $stmt->fetchAll() ?: [];
} }