File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -158,12 +158,27 @@ class ShopInBitOrdersService extends ChangeNotifier {
158158 Future <void > refreshAll () async {
159159 try {
160160 final customerKey = await shopInBitService.ensureCustomerKey ();
161+ final db = SharedDrift .get ();
162+
163+ // Backfill rows for tickets that exist on the API but not locally
164+ // (created on another device, web dashboard, etc.). A failure here
165+ // shouldn't stop the refresh of tickets we already know about.
166+ try {
167+ final newCompanions = await shopInBitService.fetchAllForCustomerKey (
168+ customerKey,
169+ );
170+ for (final companion in newCompanions) {
171+ await db.into (db.shopInBitTickets).insertOnConflictUpdate (companion);
172+ }
173+ } catch (_) {
174+ // Fall through to the refresh-existing path.
175+ }
176+
161177 final resp = await shopInBitService.client.getTicketsByCustomer (
162178 customerKey,
163179 );
164180 if (resp.hasError || resp.value == null ) return ;
165181
166- final db = SharedDrift .get ();
167182 final localRows = await db.select (db.shopInBitTickets).get ();
168183 final byApiId = {for (final r in localRows) r.apiTicketId: r};
169184
You can’t perform that action at this time.
0 commit comments