File tree Expand file tree Collapse file tree 1 file changed +20
-8
lines changed
lib/features/digital_guide/tabs/accessibility_dialog/data Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change 1+ import "dart:async" ;
12import "package:fast_immutable_collections/fast_immutable_collections.dart" ;
23import "package:riverpod_annotation/riverpod_annotation.dart" ;
34
@@ -15,14 +16,25 @@ const modes = <ModeWithKey>[
1516 HearingImpairment (),
1617];
1718
18- @riverpod
19- Future <ISet <ModeWithKey >> activeAccessibilityModesRepository (Ref ref) async {
20- final modeStatesTuples = modes.map ((mode) => (mode, ref.watch (accessibilityModeRepositoryProvider (mode))));
19+ @Riverpod (keepAlive: true )
20+ class ActiveAccessibilityModesRepository extends _$ActiveAccessibilityModesRepository {
21+ @override
22+ Future <ISet <ModeWithKey >> build () async {
23+ final previous = state.asData? .value;
2124
22- final activeModes = modeStatesTuples
23- .where ((tuple) => tuple.$2.asData? .value ?? false )
24- .map ((tuple) => tuple.$1)
25- .toISet ();
25+ if (previous != null ) {
26+ state = AsyncValue .data (previous);
27+ }
2628
27- return activeModes;
29+ final modeStates = await Future .wait (
30+ modes.map ((mode) => ref.watch (accessibilityModeRepositoryProvider (mode).future)),
31+ );
32+
33+ final activeModes = < ModeWithKey > [
34+ for (var i = 0 ; i < modes.length; i++ )
35+ if (modeStates[i]) modes[i],
36+ ].toISet ();
37+
38+ return activeModes;
39+ }
2840}
You can’t perform that action at this time.
0 commit comments