Skip to content

Commit 6da8d2f

Browse files
sneurlaxjulian-CStack
authored andcommitted
feat(shopinbit): keep polling ticket state & messages of terminal tickets
1 parent 72cff2b commit 6da8d2f

2 files changed

Lines changed: 1 addition & 20 deletions

File tree

lib/pages/shopinbit/shopinbit_ticket_detail.dart

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import '../../providers/db/drift_provider.dart';
1212
import '../../providers/global/shopin_bit_service_provider.dart';
1313
import '../../services/shopinbit/src/client.dart';
1414
import '../../services/shopinbit/src/models/message.dart';
15-
import '../../services/shopinbit/src/models/ticket.dart';
1615
import '../../themes/stack_colors.dart';
1716
import '../../utilities/assets.dart';
1817
import '../../utilities/logger.dart';
@@ -81,10 +80,7 @@ class _ShopInBitTicketDetailState extends ConsumerState<ShopInBitTicketDetail>
8180
void didChangeAppLifecycleState(AppLifecycleState state) {
8281
// Don't poll while backgrounded; resume fresh when we come back.
8382
if (state == AppLifecycleState.resumed) {
84-
final ticket = ref.read(pShopInBitTicket(_id)).asData?.value;
85-
final terminal =
86-
ticket != null && TicketState.fromString(ticket.statusRaw).isTerminal;
87-
if (!terminal) _startPolling();
83+
_startPolling();
8884
} else {
8985
_pollingTimer?.cancel();
9086
}
@@ -105,13 +101,6 @@ class _ShopInBitTicketDetailState extends ConsumerState<ShopInBitTicketDetail>
105101
}
106102
if (!mounted) return;
107103

108-
// Stop polling once the ticket reaches a terminal state; nothing about a
109-
// closed/merged/refunded ticket will change server-side.
110-
final ticket = ref.read(pShopInBitTicket(_id)).asData?.value;
111-
if (ticket != null && TicketState.fromString(ticket.statusRaw).isTerminal) {
112-
return;
113-
}
114-
115104
// Back off on failure (e.g. a 429), reset on success.
116105
_pollInterval = ok
117106
? _kBasePollInterval

lib/services/shopinbit/shopinbit_service.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,6 @@ class ShopInBitService {
182182
id,
183183
);
184184

185-
// Terminal-state short-circuit: nothing about a closed/merged ticket
186-
// will change server-side, so skip the three API calls entirely.
187-
if (existing != null &&
188-
TicketState.fromString(existing.statusRaw).isTerminal) {
189-
completer.complete();
190-
return;
191-
}
192-
193185
// get status first. If it fails there is no reason to make the remaining
194186
// two API calls
195187
final statusResp = await client.getTicketStatus(

0 commit comments

Comments
 (0)