Skip to content

Commit 08a04c5

Browse files
committed
fix(shopinbit): load offer price in ticket list/detail, add message polling, fix closed ticket messages
1 parent b296975 commit 08a04c5

2 files changed

Lines changed: 33 additions & 9 deletions

File tree

lib/pages/shopinbit/shopinbit_ticket_detail.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,26 @@ class _ShopInBitTicketDetailState extends State<ShopInBitTicketDetail> {
8080
bool _sending = false;
8181
bool _loading = false;
8282
bool _retrying = false;
83+
Timer? _pollTimer;
8384

8485
@override
8586
void initState() {
8687
super.initState();
8788
_messageController = TextEditingController();
8889
if (widget.model.apiTicketId != 0) {
8990
_loadFromApi();
91+
if (!_isCarResearch) {
92+
_pollTimer = Timer.periodic(
93+
const Duration(seconds: 30),
94+
(_) => _loadFromApi(),
95+
);
96+
}
9097
}
9198
}
9299

93100
@override
94101
void dispose() {
102+
_pollTimer?.cancel();
95103
_messageController.dispose();
96104
super.dispose();
97105
}
@@ -130,6 +138,19 @@ class _ShopInBitTicketDetailState extends State<ShopInBitTicketDetail> {
130138
statusResp.value!.state,
131139
);
132140
}
141+
142+
if (widget.model.status == ShopInBitOrderStatus.offerAvailable &&
143+
(widget.model.offerProductName == null ||
144+
widget.model.offerPrice == null)) {
145+
final offerResp = await client.getTicketFull(id);
146+
if (!offerResp.hasError && offerResp.value != null) {
147+
final t = offerResp.value!;
148+
widget.model.setOffer(
149+
productName: t.productName,
150+
price: t.customerPrice,
151+
);
152+
}
153+
}
133154
}
134155

135156
unawaited(

lib/pages/shopinbit/shopinbit_tickets_view.dart

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,6 @@ class _ShopInBitTicketsViewState extends State<ShopInBitTicketsView> {
121121
final localIdx = _tickets.indexWhere((t) => t.apiTicketId == ref.id);
122122
if (localIdx < 0) continue;
123123

124-
// Skip API calls for terminal tickets; they can still be
125-
// refreshed on-demand when the user opens the detail view.
126-
final localStatus = _tickets[localIdx].status;
127-
if (localStatus == ShopInBitOrderStatus.closed ||
128-
localStatus == ShopInBitOrderStatus.cancelled ||
129-
localStatus == ShopInBitOrderStatus.refunded) {
130-
continue;
131-
}
132-
133124
// Car research tickets return 403 on /tickets/:id/* endpoints.
134125
if (_tickets[localIdx].category == ShopInBitCategory.car) continue;
135126

@@ -140,6 +131,18 @@ class _ShopInBitTicketsViewState extends State<ShopInBitTicketsView> {
140131
statusResp.value!.state,
141132
);
142133

134+
if (_tickets[localIdx].status == ShopInBitOrderStatus.offerAvailable &&
135+
(_tickets[localIdx].offerProductName == null ||
136+
_tickets[localIdx].offerPrice == null)) {
137+
final offerResp = await service.client.getTicketFull(ref.id);
138+
if (!offerResp.hasError && offerResp.value != null) {
139+
_tickets[localIdx].setOffer(
140+
productName: offerResp.value!.productName,
141+
price: offerResp.value!.customerPrice,
142+
);
143+
}
144+
}
145+
143146
final msgsResp = await service.client.getMessages(ref.id);
144147
if (!msgsResp.hasError && msgsResp.value != null) {
145148
_tickets[localIdx].clearMessages();

0 commit comments

Comments
 (0)