refactor contaienr filter
This commit is contained in:
+5
-1
@@ -40,7 +40,11 @@ class TabSearch extends HookConsumerWidget {
|
||||
seamlessFilteredTabPreviewsProvider(
|
||||
TabSearchPartition.search,
|
||||
// ignore: provider_parameters
|
||||
ContainerFilter.from(selectedContainer.value?.id),
|
||||
selectedContainer.value?.id.mapNotNull(
|
||||
(containerId) =>
|
||||
ContainerFilterById(containerId: containerId),
|
||||
) ??
|
||||
ContainerFilterDisabled(),
|
||||
),
|
||||
)
|
||||
.value;
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
import 'package:fast_equatable/fast_equatable.dart';
|
||||
|
||||
sealed class ContainerFilter with FastEquatable {
|
||||
ContainerFilter();
|
||||
|
||||
factory ContainerFilter.from(String? containerId) {
|
||||
return (containerId != null)
|
||||
? ContainerFilterById(containerId: containerId)
|
||||
: ContainerFilterDisabled();
|
||||
}
|
||||
}
|
||||
sealed class ContainerFilter with FastEquatable {}
|
||||
|
||||
class ContainerFilterById extends ContainerFilter {
|
||||
final String? containerId;
|
||||
|
||||
@@ -144,8 +144,10 @@ Stream<ContainerData?> selectedContainerData(Ref ref) {
|
||||
AsyncValue<int> selectedContainerTabCount(Ref ref) {
|
||||
final selectedContainer = ref.watch(selectedContainerProvider);
|
||||
final tabCount = ref.watch(
|
||||
// ignore: provider_parameters
|
||||
containerTabCountProvider(ContainerFilter.from(selectedContainer)),
|
||||
containerTabCountProvider(
|
||||
// ignore: provider_parameters
|
||||
ContainerFilterById(containerId: selectedContainer),
|
||||
),
|
||||
);
|
||||
|
||||
return tabCount;
|
||||
|
||||
@@ -26,7 +26,7 @@ final selectedContainerDataProvider =
|
||||
// ignore: unused_element
|
||||
typedef SelectedContainerDataRef = AutoDisposeStreamProviderRef<ContainerData?>;
|
||||
String _$selectedContainerTabCountHash() =>
|
||||
r'60218b4a9058738dfd43628d5e3c55f93080732f';
|
||||
r'0fd457793f7870050f81c54d2fbcc81aca60f394';
|
||||
|
||||
/// See also [selectedContainerTabCount].
|
||||
@ProviderFor(selectedContainerTabCount)
|
||||
|
||||
Reference in New Issue
Block a user