Skip to content

Commit

Permalink
React to Tor/Ipfs overwritten events in domain search
Browse files Browse the repository at this point in the history
  • Loading branch information
simonesestito committed Jan 20, 2024
1 parent d18eb59 commit 581cadf
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions lib/bloc/domain_search/domain_search_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,28 @@ class DomainSearchBloc extends Bloc<DomainSearchEvent, DomainSearchState> {
// Listen for events in domains
globalEventsSink.domainTransfers.listen((event) {
debugPrint('[DomainSearchBloc] transfer event received: $event');
debugPrint(
'[DomainSearchBloc] last searched domain: ${_getLastSearchedDomain()}');
debugPrint('[DomainSearchBloc] event domain: ${event.domainName}');
_onReloadDomain(event.domainName);
});

if (_getLastSearchedDomain() == event.domainName) {
// Reload the domain
search(event.domainName);
}
// Listen for events in domain edits
globalEventsSink.domainEdits.listen((event) {
debugPrint('[DomainSearchBloc] edit event received: $event');
_onReloadDomain(event.domainName);
});
}

void _onReloadDomain(String domainName) {
debugPrint(
'[DomainSearchBloc] last searched domain: ${_getLastSearchedDomain()}',
);
debugPrint('[DomainSearchBloc] event domain: $domainName');

if (_getLastSearchedDomain() == domainName) {
// Reload the domain
search(domainName);
}
}

void search(String domain) => add(DomainSearchEventSearch(domain));

void clear() => add(const DomainSearchEventClear());
Expand Down

0 comments on commit 581cadf

Please sign in to comment.