mirror of
https://github.com/block/buzz.git
synced 2026-11-27 19:52:31 +00:00
## Why Buzz mobile now checks who signed each edit before deciding what to show in a channel or thread. That includes edits to the first message of a thread loaded from local storage. Mobile also preserves the information needed to verify edits after an offline restart and retries missing profile lookups when the app reconnects. The companion relay change is #9886. ## Mechanism Mobile uses the first valid message reference on an edit and shows the newest edit that passes its checks. It accepts edits from the original message’s signer. If the relay signed the original, mobile also accepts edits from the author named by the relay. A verified agent owner can edit the agent’s chat messages (kinds 9 and 40002) and diff messages (kind 40008) in the same channel. **Agent owners.** Mobile verifies the owner named in the agent’s signed profile. The app reads permission when a user opens the channel or thread message menu or the image actions. The native photo viewer also reads permission when it opens and checks again before deleting. These paths and the timeline use the same signed profile to verify the owner. When an agent’s signed profile names an owner, mobile saves the signed event once and reads fields such as the name and avatar from it on restart. If that entry exceeds the 16 KiB limit, mobile saves the display fields alone if they fit. Mobile needs the signed profile to verify the owner. When the app connects, it asks for profiles needed to check edits in the current timeline and retries unresolved lookups on reconnect. The cache skips profiles it has already checked with the relay and public keys the relay recently reported as having no profile. Once mobile loads a newer profile from the relay that no longer names the owner, it stops applying that person’s edits. The next time that person opens the message menu, Edit is absent. In the device test, both changes took effect after restarting the app. **Relay signing key.** While connected, mobile looks up the key if the timeline contains an edit whose signer differs from the original message’s signer and the original has a public key in an `actor` or `p` tag. A mention in a `p` tag can also trigger the lookup. Mobile uses that tagged author only after confirming that the relay signed the original message. Mobile keeps the last key during reconnects and can read it from the saved-message store after an offline restart. If the timeline still needs the key when mobile reconnects, mobile refreshes it so a rotated key can take effect during the same session. A failed request or a response without a key leaves the previous key available. Thread summaries read the key available when they refresh and start no key lookup. ## What changed - Start with `edit_authority.dart` for the profile and key lookups and the permission check that runs when actions open. See `timeline_message.dart` for edit selection and `thread_detail_helpers.dart` for the first message of a thread loaded from local storage. - See `verified_profile_owner.dart` for ownership verification, `profile_snapshot.dart` for storage and restore, `user_cache_provider.dart` for profile refreshes, and `SavedMessageStore.relayAuthor` for the saved relay key. - Tests cover edit selection, owner edits to chat and diff messages, and edits to a saved thread’s first message after replies load. They also cover opening message and image actions, restored profiles without a signed copy and profiles signed by the wrong key, reconnect retries, offline reopening with a large signed profile, and a newly fetched relay key replacing a saved key. Tests also verify that the native photo viewer blocks deletion if permission is withdrawn while it is open, that opening message actions requests a fresh profile when the saved profile names the viewer as owner but lacks a signed copy, and that a tampered saved profile cannot verify ownership. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Stephen Edwards <sedwards@squareup.com>
528 lines
19 KiB
Dart
528 lines
19 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
import '../relay/relay.dart';
|
|
import '../verified_profiles/verified_profile_directory.dart';
|
|
import 'user_profile.dart';
|
|
import 'profile_event_parser.dart';
|
|
import 'profile_snapshot.dart';
|
|
|
|
/// Cache of user profiles, fetched in batches from the relay.
|
|
///
|
|
/// Verified profiles persist per identity and relay ([ProfileSnapshotStorage])
|
|
/// so names and avatars render on launch, even on a slow link. Restored
|
|
/// profiles are served immediately and revalidated on their first lookup.
|
|
///
|
|
/// Lookups requested via [get] or [preload] are coalesced into a single
|
|
/// kind:0 batch query (NIP-01 `authors` filter) every 50ms. Larger requests
|
|
/// drain sequentially in pages bounded by the relay response limit.
|
|
class UserCacheNotifier extends Notifier<Map<String, UserProfile>> {
|
|
// The relay clamps each history response to DEFAULT_MAX_PAGE_LIMIT (1000).
|
|
static const _maximumProfilesPerQuery = 1000;
|
|
static const _snapshotWriteDelay = Duration(seconds: 2);
|
|
|
|
final Set<String> _pending = {};
|
|
final Map<String, ({int createdAt, String eventId})> _profileEventOrders = {};
|
|
int _generation = 0;
|
|
bool _flushInFlight = false;
|
|
Future<void> _verificationQueue = Future.value();
|
|
Timer? _batchTimer;
|
|
Completer<bool>? _batchCompleter;
|
|
|
|
/// Restored from the snapshot and not yet checked with the relay this scope.
|
|
final Set<String> _unrevalidated = {};
|
|
|
|
/// Lookups whose batch query is on the wire.
|
|
final Set<String> _inFlight = {};
|
|
|
|
/// Keys the relay confirmed have no profile this scope, with when it said
|
|
/// so: [requestLinked] skips them until [_absentFor] passes, so a link to a
|
|
/// nameless key costs one query, not one per rebuild.
|
|
final Map<String, DateTime> _absentSince = {};
|
|
static const _absentFor = Duration(minutes: 5);
|
|
|
|
/// Keys [requestLinked] asked for that no batch has answered yet. A failed
|
|
/// batch leaves them here, and the next reconnect asks once more.
|
|
final Set<String> _linkedUnanswered = {};
|
|
ProviderSubscription<SessionStatus>? _reconnects;
|
|
|
|
/// A reconnect came while unanswered keys were still in flight, so they
|
|
/// are asked again once that flight settles.
|
|
var _retryAfterFlight = false;
|
|
static const _maxAbsent = 1000;
|
|
|
|
/// Completes when the batch query on the wire has finished.
|
|
Completer<bool>? _flightCompleter;
|
|
void Function()? _snapshotWriter;
|
|
Timer? _snapshotTimer;
|
|
Map<String, UserProfile> _latest = const {};
|
|
|
|
@override
|
|
Map<String, UserProfile> build() {
|
|
final config = ref.watch(relayConfigProvider);
|
|
_generation++;
|
|
_profileEventOrders.clear();
|
|
_unrevalidated.clear();
|
|
_inFlight.clear();
|
|
_absentSince.clear();
|
|
_linkedUnanswered.clear();
|
|
_retryAfterFlight = false;
|
|
// A rebuild closes the subscription, so the next link opens a new one.
|
|
_reconnects = null;
|
|
ref.onDispose(() {
|
|
_generation++;
|
|
_pending.clear();
|
|
_batchTimer?.cancel();
|
|
_batchTimer = null;
|
|
_batchCompleter?.complete(false);
|
|
_batchCompleter = null;
|
|
// Flush rather than drop: switching community must not lose the
|
|
// profiles learned since the last write.
|
|
if (_snapshotTimer?.isActive ?? false) _snapshotWriter?.call();
|
|
_snapshotTimer?.cancel();
|
|
_snapshotTimer = null;
|
|
_snapshotWriter = null;
|
|
});
|
|
return _restoreSnapshot(config);
|
|
}
|
|
|
|
Map<String, UserProfile> _restoreSnapshot(RelayConfig config) {
|
|
final storage = ref.read(profileSnapshotStorageProvider);
|
|
final pubkey = pubkeyFromNsec(config.nsec);
|
|
if (storage == null || pubkey == null) return {};
|
|
final relay = config.baseUrl;
|
|
final token = storage.capture(pubkey, relay);
|
|
_snapshotWriter = () {
|
|
final profiles = [
|
|
for (final MapEntry(:key, value: order) in _profileEventOrders.entries)
|
|
if (_latest[key] case final profile?)
|
|
(
|
|
profile: profile,
|
|
createdAt: order.createdAt,
|
|
eventId: order.eventId,
|
|
),
|
|
];
|
|
storage
|
|
.write(token, profiles)
|
|
.then(
|
|
(saved) {
|
|
if (!saved) debugPrint('[UserCache] snapshot was not saved');
|
|
},
|
|
onError: (Object error, StackTrace stack) {
|
|
debugPrint('[UserCache] snapshot write failed: $error');
|
|
},
|
|
);
|
|
};
|
|
final restored = <String, UserProfile>{};
|
|
for (final parsed in storage.read(pubkey, relay)) {
|
|
final key = parsed.profile.pubkey;
|
|
restored[key] = parsed.profile;
|
|
_profileEventOrders[key] = (
|
|
createdAt: parsed.createdAt,
|
|
eventId: parsed.eventId,
|
|
);
|
|
_unrevalidated.add(key);
|
|
}
|
|
return _latest = restored;
|
|
}
|
|
|
|
@override
|
|
set state(Map<String, UserProfile> value) {
|
|
super.state = _latest = value;
|
|
if (_snapshotWriter == null) return;
|
|
_snapshotTimer ??= Timer(_snapshotWriteDelay, () {
|
|
_snapshotTimer = null;
|
|
_snapshotWriter?.call();
|
|
});
|
|
}
|
|
|
|
/// Whether [pubkey] has a profile that is current for this scope.
|
|
bool _isCached(String pubkey) =>
|
|
state.containsKey(pubkey) && !_unrevalidated.contains(pubkey);
|
|
|
|
/// Request a profile for [pubkey]. Returns immediately from cache if
|
|
/// available, otherwise schedules a batch fetch.
|
|
UserProfile? get(String pubkey) {
|
|
_trackVerified([pubkey]);
|
|
final key = pubkey.toLowerCase();
|
|
_scheduleFetch(key);
|
|
return state[key];
|
|
}
|
|
|
|
/// Whether [requestLinked] would ask the relay for [pubkey], or enroll it
|
|
/// for the reconnect retry: it has no profile, or only a restored one not
|
|
/// yet revalidated, and no recent answer said it has none. A key another
|
|
/// lookup already has on the way still enrolls once, so a link to it is
|
|
/// retried if that batch fails. Cheap, so a build can check it.
|
|
bool needsLinkedLookup(String pubkey) {
|
|
final key = pubkey.toLowerCase();
|
|
if (_isCached(key)) return false;
|
|
if (_pending.contains(key) || _inFlight.contains(key)) {
|
|
return !_linkedUnanswered.contains(key);
|
|
}
|
|
final absent = _absentSince[key];
|
|
return absent == null || DateTime.now().difference(absent) >= _absentFor;
|
|
}
|
|
|
|
/// Requests profiles for keys named outside any roster, such as by
|
|
/// identity links or edits. Restored profiles are revalidated, so a
|
|
/// renamed key's link shows its current name, and a restored owner hint
|
|
/// gets its signed profile; a key the relay just said has no profile is
|
|
/// not asked again for [_absentFor]; and a failed batch is retried once
|
|
/// the relay reconnects. Coalesced with every other lookup.
|
|
void requestLinked(Iterable<String> pubkeys) {
|
|
final keys = [
|
|
for (final pubkey in pubkeys)
|
|
if (needsLinkedLookup(pubkey)) pubkey.toLowerCase(),
|
|
];
|
|
if (keys.isEmpty) return;
|
|
_trackVerified(keys);
|
|
_linkedUnanswered.addAll(keys);
|
|
// Bounded like the absent answers: the oldest unanswered key goes first.
|
|
while (_linkedUnanswered.length > _maxAbsent) {
|
|
_linkedUnanswered.remove(_linkedUnanswered.first);
|
|
}
|
|
keys.forEach(_scheduleFetch);
|
|
_reconnects ??= ref.listen(
|
|
relaySessionProvider.select((session) => session.status),
|
|
(previous, next) {
|
|
if (next == SessionStatus.connected &&
|
|
previous != SessionStatus.connected) {
|
|
_linkedUnanswered.forEach(_scheduleFetch);
|
|
if (_linkedUnanswered.any(_inFlight.contains)) {
|
|
_retryAfterFlight = true;
|
|
}
|
|
}
|
|
},
|
|
);
|
|
}
|
|
|
|
/// Stores a profile that was fetched or updated outside the batch loader.
|
|
void put(UserProfile profile) {
|
|
state = {...state, profile.pubkey.toLowerCase(): profile};
|
|
}
|
|
|
|
/// Resolves profiles through verified batch admission.
|
|
///
|
|
/// Unlike [preload], failures propagate to callers whose result requires
|
|
/// profile hydration. Set [refreshCached] for a full revalidation; otherwise
|
|
/// cached profiles remain reusable within this scope.
|
|
Future<Map<String, UserProfile>> resolve(
|
|
List<String> pubkeys, {
|
|
bool refreshCached = false,
|
|
}) async {
|
|
final requested = pubkeys.map((pubkey) => pubkey.toLowerCase()).toSet();
|
|
_trackVerified(requested);
|
|
final toFetch = requested
|
|
.where((pubkey) => refreshCached || !_isCached(pubkey))
|
|
.toList();
|
|
final generation = _generation;
|
|
final session = ref.read(relaySessionProvider.notifier);
|
|
for (final batch in _profileQueryBatches(toFetch)) {
|
|
if (!_isCurrent(generation)) {
|
|
throw StateError('Profile request belongs to a retired cache');
|
|
}
|
|
final events = await session.fetchHistory(
|
|
NostrFilters.profilesBatch(batch),
|
|
);
|
|
if (!await _verifyAndMerge(events, generation)) {
|
|
throw StateError('Profile request belongs to a retired cache');
|
|
}
|
|
}
|
|
if (!_isCurrent(generation)) {
|
|
throw StateError('Profile request belongs to a retired cache');
|
|
}
|
|
_unrevalidated.removeAll(toFetch);
|
|
return {for (final pubkey in requested) pubkey: ?state[pubkey]};
|
|
}
|
|
|
|
/// Preload profiles for a list of pubkeys (e.g. channel members).
|
|
/// Returns whether the batch completed successfully.
|
|
Future<bool> preload(List<String> pubkeys) {
|
|
_trackVerified(pubkeys);
|
|
final normalized = pubkeys.map((pk) => pk.toLowerCase()).toSet();
|
|
// Restored profiles being revalidated already render; don't wait on them.
|
|
final alreadyPending = normalized.any(
|
|
(pk) => _pending.contains(pk) && !state.containsKey(pk),
|
|
);
|
|
// A batch already on the wire answers these; asking again would download
|
|
// the same profiles twice.
|
|
final flight = _flightCompleter;
|
|
final awaitsFlight =
|
|
flight != null &&
|
|
normalized.any(
|
|
(pk) => _inFlight.contains(pk) && !state.containsKey(pk),
|
|
);
|
|
final uncached = normalized
|
|
.where(
|
|
(pk) =>
|
|
!state.containsKey(pk) &&
|
|
!_pending.contains(pk) &&
|
|
!_inFlight.contains(pk),
|
|
)
|
|
.toList();
|
|
// Restored profiles already render; revalidate them without making the
|
|
// caller wait on the network.
|
|
normalized.where(_unrevalidated.contains).forEach(_scheduleFetch);
|
|
if (uncached.isEmpty && !alreadyPending) {
|
|
return awaitsFlight ? flight.future : Future.value(true);
|
|
}
|
|
_pending.addAll(uncached);
|
|
final completer = _batchCompleter ??= Completer<bool>();
|
|
_scheduleBatch();
|
|
if (!awaitsFlight) return completer.future;
|
|
return Future.wait([
|
|
flight.future,
|
|
completer.future,
|
|
]).then((results) => results.every((succeeded) => succeeded));
|
|
}
|
|
|
|
/// Force-refresh profiles for identity-sensitive gates.
|
|
///
|
|
/// Unlike [preload], this fetches cached pubkeys too so stale human profiles
|
|
/// cannot be trusted after a verified agent-owner profile was published.
|
|
Future<bool> refresh(List<String> pubkeys) async {
|
|
final normalized = pubkeys
|
|
.map((pubkey) => pubkey.toLowerCase())
|
|
.where((pubkey) => pubkey.isNotEmpty)
|
|
.toSet()
|
|
.toList();
|
|
if (normalized.isEmpty) return true;
|
|
_trackVerified(normalized);
|
|
final generation = _generation;
|
|
try {
|
|
final session = ref.read(relaySessionProvider.notifier);
|
|
for (final batch in _profileQueryBatches(normalized)) {
|
|
if (!_isCurrent(generation)) return false;
|
|
final events = await session.fetchHistory(
|
|
NostrFilters.profilesBatch(batch),
|
|
);
|
|
if (!_isCurrent(generation)) return false;
|
|
if (!await _verifyAndMerge(events, generation)) return false;
|
|
}
|
|
_unrevalidated.removeAll(normalized);
|
|
return true;
|
|
} catch (_) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// Applies a live kind:0 profile event to the cache.
|
|
///
|
|
/// Surfaces that keep a participant-scoped profile subscription can use this
|
|
/// to update names and avatars without discarding the rest of the cache.
|
|
void cacheProfileEvent(NostrEvent event) {
|
|
if (event.kind != 0) return;
|
|
final updated = Map<String, UserProfile>.from(state);
|
|
if (_cacheProfileEvent(event, updated)) state = updated;
|
|
}
|
|
|
|
/// Anyone whose name is needed may also have a NIP-FI verified name.
|
|
void _trackVerified(Iterable<String> pubkeys) =>
|
|
ref.read(verifiedProfilesProvider.notifier).track(pubkeys);
|
|
|
|
void _scheduleFetch(String pubkey) {
|
|
if (_isCached(pubkey) ||
|
|
_pending.contains(pubkey) ||
|
|
_inFlight.contains(pubkey)) {
|
|
return;
|
|
}
|
|
_pending.add(pubkey);
|
|
_batchCompleter ??= Completer<bool>();
|
|
_scheduleBatch();
|
|
}
|
|
|
|
Future<void> _flushPending() async {
|
|
_batchTimer = null;
|
|
if (_pending.isEmpty) return;
|
|
|
|
final pubkeys = _pending.toList();
|
|
_pending.clear();
|
|
final completer = _batchCompleter ?? Completer<bool>();
|
|
_batchCompleter = null;
|
|
_flightCompleter = completer;
|
|
|
|
_flushInFlight = true;
|
|
_inFlight.addAll(pubkeys);
|
|
final generation = _generation;
|
|
var succeeded = false;
|
|
try {
|
|
final session = ref.read(relaySessionProvider.notifier);
|
|
var remaining = pubkeys.length;
|
|
for (final batch in _profileQueryBatches(pubkeys)) {
|
|
if (!_isCurrent(generation)) return;
|
|
final events = await session.fetchHistory(
|
|
NostrFilters.profilesBatch(batch),
|
|
);
|
|
if (!_isCurrent(generation)) return;
|
|
if (!await _verifyAndMerge(events, generation)) return;
|
|
// Confirmed by the relay, whether or not it still has a profile.
|
|
_unrevalidated.removeAll(batch);
|
|
_linkedUnanswered.removeAll(batch);
|
|
final answered = DateTime.now();
|
|
for (final pubkey in batch) {
|
|
if (state.containsKey(pubkey)) continue;
|
|
// Reinserted at the end, so the oldest answer is evicted first.
|
|
_absentSince
|
|
..remove(pubkey)
|
|
..[pubkey] = answered;
|
|
if (_absentSince.length > _maxAbsent) {
|
|
_absentSince.remove(_absentSince.keys.first);
|
|
}
|
|
}
|
|
remaining -= batch.length;
|
|
if (remaining == 0) {
|
|
// All requested pages are ready.
|
|
succeeded = true;
|
|
completer.complete(true);
|
|
}
|
|
}
|
|
} catch (_) {
|
|
// Silently fail — non-gating callers will just show pubkeys, or the
|
|
// restored profile, which the next lookup revalidates again.
|
|
} finally {
|
|
if (_isCurrent(generation)) {
|
|
_inFlight.removeAll(pubkeys);
|
|
if (_retryAfterFlight && ref.mounted) {
|
|
_retryAfterFlight = false;
|
|
_linkedUnanswered.forEach(_scheduleFetch);
|
|
}
|
|
}
|
|
if (!completer.isCompleted) completer.complete(succeeded);
|
|
if (identical(_flightCompleter, completer)) _flightCompleter = null;
|
|
_flushInFlight = false;
|
|
if (ref.mounted && _pending.isNotEmpty) _scheduleBatch();
|
|
}
|
|
}
|
|
|
|
Iterable<List<String>> _profileQueryBatches(List<String> pubkeys) sync* {
|
|
for (
|
|
var start = 0;
|
|
start < pubkeys.length;
|
|
start += _maximumProfilesPerQuery
|
|
) {
|
|
final end = start + _maximumProfilesPerQuery;
|
|
yield pubkeys.sublist(start, end < pubkeys.length ? end : pubkeys.length);
|
|
}
|
|
}
|
|
|
|
void _scheduleBatch() {
|
|
if (_flushInFlight) return;
|
|
_batchTimer ??= Timer(const Duration(milliseconds: 50), _flushPending);
|
|
}
|
|
|
|
Future<bool> _verifyAndMerge(List<NostrEvent> events, int generation) {
|
|
// Both refresh and preload share one worker slot. Keep this queue across
|
|
// community changes so an old worker cannot overlap a new community's job.
|
|
final result = _verificationQueue.then((_) async {
|
|
if (!_isCurrent(generation)) return false;
|
|
// Match live-cache admission before parsing. In particular, a malformed
|
|
// stale profile must not fail a refresh that previously ignored it.
|
|
final pending = [
|
|
for (final event in events)
|
|
if (event.kind == 0 &&
|
|
_admits(
|
|
event.pubkey.toLowerCase(),
|
|
event.createdAt,
|
|
event.id,
|
|
evidence: carriesOwnerAttestation(event),
|
|
))
|
|
event,
|
|
];
|
|
if (pending.isEmpty) return true;
|
|
final profiles = await ref.read(profileEventBatchParserProvider)(pending);
|
|
if (!_isCurrent(generation)) return false;
|
|
_mergeParsedProfiles(profiles);
|
|
return true;
|
|
});
|
|
// Callers receive the original error; only the sequencing tail recovers so
|
|
// one rejected batch does not poison all future refreshes.
|
|
_verificationQueue = result.then<void>(
|
|
(_) {},
|
|
onError: (Object error, StackTrace stack) {},
|
|
);
|
|
return result;
|
|
}
|
|
|
|
bool _isCurrent(int generation) => ref.mounted && generation == _generation;
|
|
|
|
void _mergeParsedProfiles(List<ParsedProfileEvent> profiles) {
|
|
// Read the current state after the isolate completes: live events and other
|
|
// batches may have installed newer profiles while this batch was parsing.
|
|
final updated = Map<String, UserProfile>.from(state);
|
|
var changed = false;
|
|
for (final parsed in profiles) {
|
|
if (!_admits(
|
|
parsed.profile.pubkey,
|
|
parsed.createdAt,
|
|
parsed.eventId,
|
|
evidence: parsed.profile.ownerEvidence != null,
|
|
)) {
|
|
continue;
|
|
}
|
|
updated[parsed.profile.pubkey] = parsed.profile;
|
|
_profileEventOrders[parsed.profile.pubkey] = (
|
|
createdAt: parsed.createdAt,
|
|
eventId: parsed.eventId,
|
|
);
|
|
changed = true;
|
|
}
|
|
if (changed) state = updated;
|
|
}
|
|
|
|
bool _isNewer(String pubkey, int createdAt, String eventId) {
|
|
final current = _profileEventOrders[pubkey];
|
|
return current == null ||
|
|
createdAt > current.createdAt ||
|
|
(createdAt == current.createdAt &&
|
|
eventId.compareTo(current.eventId) < 0);
|
|
}
|
|
|
|
/// Whether a profile event replaces the stored one: it is newer, or it is
|
|
/// the stored event itself and brings the owner evidence the stored copy
|
|
/// lacks (restored from a snapshot written without it).
|
|
bool _admits(
|
|
String pubkey,
|
|
int createdAt,
|
|
String eventId, {
|
|
required bool evidence,
|
|
}) =>
|
|
_isNewer(pubkey, createdAt, eventId) ||
|
|
(evidence &&
|
|
_profileEventOrders[pubkey]?.eventId == eventId &&
|
|
state[pubkey]?.ownerEvidence == null);
|
|
|
|
bool _cacheProfileEvent(NostrEvent event, Map<String, UserProfile> profiles) {
|
|
if (event.kind != 0) return false;
|
|
final pubkey = event.pubkey.toLowerCase();
|
|
if (!_admits(
|
|
pubkey,
|
|
event.createdAt,
|
|
event.id,
|
|
evidence: carriesOwnerAttestation(event),
|
|
)) {
|
|
return false;
|
|
}
|
|
profiles[pubkey] = parseProfileEvent(event).profile;
|
|
_profileEventOrders[pubkey] = (
|
|
createdAt: event.createdAt,
|
|
eventId: event.id,
|
|
);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/// Profile history parser, isolated from provider state so batch completion can
|
|
/// be delayed independently of relay delivery.
|
|
final profileEventBatchParserProvider =
|
|
Provider<Future<List<ParsedProfileEvent>> Function(List<NostrEvent>)>(
|
|
(ref) => parseProfileEventBatch,
|
|
);
|
|
|
|
final userCacheProvider =
|
|
NotifierProvider<UserCacheNotifier, Map<String, UserProfile>>(
|
|
UserCacheNotifier.new,
|
|
);
|