Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions lib/features/trades/screens/trade_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1136,8 +1136,23 @@ class _CountdownWidget extends ConsumerWidget {

/// Find the message that triggered the current state
/// Returns null if no valid message is found
/// Memo per history-list instance: the index emits a new list only on real
/// changes, while the 1 s countdown tick rebuilds with the same instance —
/// the copy+sort below used to run every second.
static final Expando<Map<Status, MostroMessage?>> _stateMessageMemo =
Expando();

MostroMessage? _findMessageForState(
List<MostroMessage> messages, Status status) {
final memo = _stateMessageMemo[messages] ??= {};
if (memo.containsKey(status)) return memo[status];
final result = _findMessageForStateUncached(messages, status);
memo[status] = result;
Comment thread
grunch marked this conversation as resolved.
Outdated
return result;
}

MostroMessage? _findMessageForStateUncached(
List<MostroMessage> messages, Status status) {
// Filter out messages with invalid timestamps
final validMessages =
messages.where((m) => m.timestamp != null && m.timestamp! > 0).toList();
Expand Down
5 changes: 5 additions & 0 deletions lib/services/nwc/nwc_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,14 @@ class NwcClient {
// Only filter by kind + author; some NWC relay implementations
// (e.g. Primal) don't support #e / #p tag filters, so we verify
// the e-tag match in the event handler below.
// `since` bounds the replay: without it every request re-received the
// wallet's whole kind-23195 history from the relay (and the balance
// tick sends one request per minute). Responses are always newer than
// the request; one minute absorbs clock skew.
final filter = NostrFilter(
kinds: const [23195],
authors: [connection.walletPubkey],
since: DateTime.now().subtract(const Duration(minutes: 1)),
Comment thread
grunch marked this conversation as resolved.
Outdated
);

final subId = 'nwc_${requestId.substring(0, 8)}';
Expand Down
Loading