Only reacts to events of the same account

This commit is contained in:
Ming Ming 2021-11-22 16:36:10 +08:00
parent f9ae813613
commit 4ef2431c83

View file

@ -201,11 +201,13 @@ class ListSharingBloc extends Bloc<ListSharingBlocEvent, ListSharingBlocState> {
}
void _onShareRemovedEvent(ShareRemovedEvent ev) {
_refreshThrottler.trigger(
maxResponceTime: const Duration(seconds: 3),
maxPendingCount: 10,
data: ev.share,
);
if (_isAccountOfInterest(ev.account)) {
_refreshThrottler.trigger(
maxResponceTime: const Duration(seconds: 3),
maxPendingCount: 10,
data: ev.share,
);
}
}
Future<List<ListSharingItem>> _query(ListSharingBlocQuery ev) async {
@ -342,6 +344,9 @@ class ListSharingBloc extends Bloc<ListSharingBlocEvent, ListSharingBlocState> {
}
}
bool _isAccountOfInterest(Account account) =>
state.account == null || state.account!.compareServerIdentity(account);
late final _shareRemovedListener =
AppEventListener<ShareRemovedEvent>(_onShareRemovedEvent);