Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions lib/db/drift/shared_db/shared_database.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/db/drift/shared_db/tables/shopin_bit_tickets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ShopInBitTickets extends Table {

IntColumn get category => intEnum<ShopInBitCategory>()();
IntColumn get status => intEnum<ShopInBitOrderStatus>()();
TextColumn get statusRaw => text().nullable()();

TextColumn get requestDescription => text()();
TextColumn get deliveryCountry => text()();
Expand Down
19 changes: 18 additions & 1 deletion lib/models/shopinbit/shopinbit_order_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ class ShopInBitOrderModel extends ChangeNotifier {
}
}

// The most recent raw API state string, persisted alongside _status so that
// we can recover from contract drift (renames / new states) without losing
// history. _status is the parsed/mapped value; _statusRaw is the source of
// truth straight from the API.
String? _statusRaw;
String? get statusRaw => _statusRaw;
set statusRaw(String? value) {
if (_statusRaw != value) {
_statusRaw = value;
notifyListeners();
}
}

String? _offerProductName;
String? get offerProductName => _offerProductName;

Expand Down Expand Up @@ -277,6 +290,7 @@ class ShopInBitOrderModel extends ChangeNotifier {
displayName: Value(_displayName),
category: Value(_category ?? ShopInBitCategory.concierge),
status: Value(_status),
statusRaw: Value(_statusRaw),
requestDescription: Value(_requestDescription),
deliveryCountry: Value(_deliveryCountry),
offerProductName: Value(_offerProductName),
Expand Down Expand Up @@ -316,6 +330,7 @@ class ShopInBitOrderModel extends ChangeNotifier {
.._apiTicketId = ticket.apiTicketId
.._ticketId = ticket.ticketId
.._status = ticket.status
.._statusRaw = ticket.statusRaw
.._requestDescription = ticket.requestDescription
.._deliveryCountry = ticket.deliveryCountry
.._offerProductName = ticket.offerProductName
Expand All @@ -335,7 +350,7 @@ class ShopInBitOrderModel extends ChangeNotifier {
.._messages = messages;
}

static ShopInBitOrderStatus statusFromTicketState(TicketState state) {
static ShopInBitOrderStatus? statusFromTicketState(TicketState state) {
switch (state) {
case TicketState.newTicket:
return ShopInBitOrderStatus.pending;
Expand All @@ -360,6 +375,8 @@ class ShopInBitOrderModel extends ChangeNotifier {
return ShopInBitOrderStatus.cancelled;
case TicketState.refunded:
return ShopInBitOrderStatus.refunded;
case TicketState.unknown:
return null;
}
}
}
3 changes: 2 additions & 1 deletion lib/services/shopinbit/shopinbit_orders_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class ShopInBitOrdersService extends ChangeNotifier {
final newStatus = ShopInBitOrderModel.statusFromTicketState(
statusResp.value!.state,
);
if (model.status != newStatus) {
model.statusRaw = statusResp.value!.stateRaw;
if (model.status != newStatus && newStatus != null) {
model.status = newStatus;
changed = true;
}
Expand Down
Loading
Loading