Skip to content

Commit

Permalink
Fix: Persist payment list (#232)
Browse files Browse the repository at this point in the history
* fix: Persist payment list

* force update payment list upon receiving first sync event

* Fire `didCompleteInitialSync` event after wallet data is fetched
  • Loading branch information
erdemyerebasmaz authored Nov 12, 2024
1 parent 65b0cce commit 1be822d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/cubit/payments/payments_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ class PaymentsState {

factory PaymentsState.fromJson(Map<String, dynamic> json) {
return PaymentsState(
payments: json['payments'].map((paymentJson) => PaymentData.fromJson(paymentJson)).toList(),
payments: (json['payments'] as List<dynamic>?)
?.map((paymentJson) => PaymentData.fromJson(paymentJson))
.toList() ??
[],
paymentFilters: PaymentFilters.fromJson(json["paymentFilters"]),
);
}
Expand Down
5 changes: 3 additions & 2 deletions packages/breez_sdk_liquid/lib/src/breez_sdk_liquid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ class BreezSDKLiquid {
_paymentEventStream.add(PaymentEvent.fromSdkEvent(event));
} else if (event is liquid_sdk.SdkEvent_PaymentFailed) {
_paymentEventStream.addError(event);
} else if (event is liquid_sdk.SdkEvent_Synced) {
_didCompleteInitialSyncController.add(null);
}
await _fetchWalletData(sdk);
if (event is liquid_sdk.SdkEvent_Synced) {
_didCompleteInitialSyncController.add(null);
}
},
);
}
Expand Down

0 comments on commit 1be822d

Please sign in to comment.