apply content blocking
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import 'package:bang_navigator/features/content_block/domain/repositories/host.dart';
|
||||
import 'package:bang_navigator/features/settings/data/repositories/settings_repository.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'providers.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
Stream<Set<String>?> blockContentHosts(BlockContentHostsRef ref) {
|
||||
final hostRepository = ref.watch(hostRepositoryProvider.notifier);
|
||||
final enableContentBlocking = ref.watch(
|
||||
settingsRepositoryProvider
|
||||
.select((value) => value.valueOrNull?.enableContentBlocking ?? false),
|
||||
);
|
||||
final enableHostList = ref.watch(
|
||||
settingsRepositoryProvider
|
||||
.select((value) => value.valueOrNull?.enableHostList ?? {}),
|
||||
);
|
||||
|
||||
if (!enableContentBlocking || enableHostList.isEmpty) {
|
||||
return Stream.value(null);
|
||||
}
|
||||
|
||||
return hostRepository
|
||||
.watchHosts(sources: enableHostList)
|
||||
.map((hosts) => hosts.toSet());
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'providers.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$blockContentHostsHash() => r'27e7902adda8d8d3b6d29fdc43c5d7ad5c3a8e9a';
|
||||
|
||||
/// See also [blockContentHosts].
|
||||
@ProviderFor(blockContentHosts)
|
||||
final blockContentHostsProvider = StreamProvider<Set<String>?>.internal(
|
||||
blockContentHosts,
|
||||
name: r'blockContentHostsProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$blockContentHostsHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef BlockContentHostsRef = StreamProviderRef<Set<String>?>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||
Reference in New Issue
Block a user