File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,6 +164,18 @@ class ShopInBitService {
164164 ) async {
165165 final int id = ref.id;
166166 try {
167+ final ShopInBitTicket ? existing = await db.shopInBitTicketsDao.getByApiId (
168+ id,
169+ );
170+
171+ // Terminal-state short-circuit: nothing about a closed/merged ticket
172+ // will change server-side, so skip the three API calls entirely.
173+ if (existing != null &&
174+ TicketState .fromString (existing.statusRaw).isTerminal) {
175+ completer.complete ();
176+ return ;
177+ }
178+
167179 // Ensure the client points at the right key for this ticket's calls.
168180 client.externalCustomerKey = customerKey;
169181
@@ -176,10 +188,6 @@ class ShopInBitService {
176188 client.getMessages (id),
177189 ).wait;
178190
179- final ShopInBitTicket ? existing = await db.shopInBitTicketsDao.getByApiId (
180- id,
181- );
182-
183191 if (existing == null ) {
184192 await _insertHydrated (
185193 ref: ref,
Original file line number Diff line number Diff line change @@ -33,6 +33,11 @@ enum TicketState {
3333 );
3434 return TicketState .unknown;
3535 }
36+
37+ bool get isTerminal => switch (this ) {
38+ .closed || .closedCancelled || .merged => true ,
39+ _ => false ,
40+ } ;
3641}
3742
3843class TicketRef {
You can’t perform that action at this time.
0 commit comments