diff --git a/integration_test/add_tokens_test.dart b/integration_test/add_tokens_test.dart index c09fdefa4..c58d59f2b 100644 --- a/integration_test/add_tokens_test.dart +++ b/integration_test/add_tokens_test.dart @@ -16,7 +16,7 @@ import 'package:privacyidea_authenticator/utils/riverpod/state_notifiers/token_f import 'package:privacyidea_authenticator/utils/riverpod/state_notifiers/token_notifier.dart'; import 'package:privacyidea_authenticator/utils/customization/application_customization.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/introduction_provider.dart'; -import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/token_folder_provider.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/token_provider.dart'; import 'package:privacyidea_authenticator/views/add_token_manually_view/add_token_manually_view.dart'; diff --git a/integration_test/copy_to_clipboard_test.dart b/integration_test/copy_to_clipboard_test.dart index 9ec907a1d..707538df0 100644 --- a/integration_test/copy_to_clipboard_test.dart +++ b/integration_test/copy_to_clipboard_test.dart @@ -14,7 +14,7 @@ import 'package:privacyidea_authenticator/utils/riverpod/state_notifiers/token_n import 'package:privacyidea_authenticator/utils/customization/application_customization.dart'; import 'package:privacyidea_authenticator/model/version.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/introduction_provider.dart'; -import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/token_folder_provider.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/token_provider.dart'; diff --git a/integration_test/rename_and_delete_test.dart b/integration_test/rename_and_delete_test.dart index 5b11f9f59..ed118ca14 100644 --- a/integration_test/rename_and_delete_test.dart +++ b/integration_test/rename_and_delete_test.dart @@ -15,7 +15,7 @@ import 'package:privacyidea_authenticator/utils/riverpod/state_notifiers/token_n import 'package:privacyidea_authenticator/utils/customization/application_customization.dart'; import 'package:privacyidea_authenticator/model/version.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/introduction_provider.dart'; -import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/token_folder_provider.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/token_provider.dart'; import 'package:privacyidea_authenticator/views/main_view/main_view_widgets/token_widgets/default_token_actions/default_delete_action.dart'; diff --git a/integration_test/two_step_rollout_test.dart b/integration_test/two_step_rollout_test.dart index f2bb801fc..6b690c581 100644 --- a/integration_test/two_step_rollout_test.dart +++ b/integration_test/two_step_rollout_test.dart @@ -14,7 +14,7 @@ import 'package:privacyidea_authenticator/utils/globals.dart'; import 'package:privacyidea_authenticator/utils/logger.dart'; import 'package:privacyidea_authenticator/model/version.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/introduction_provider.dart'; -import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/token_folder_provider.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/token_provider.dart'; import 'package:privacyidea_authenticator/views/main_view/main_view.dart'; diff --git a/integration_test/views_test.dart b/integration_test/views_test.dart index 5366ba1a4..56d7f65f7 100644 --- a/integration_test/views_test.dart +++ b/integration_test/views_test.dart @@ -20,7 +20,7 @@ import 'package:privacyidea_authenticator/utils/customization/application_custom import 'package:privacyidea_authenticator/utils/globals.dart'; import 'package:privacyidea_authenticator/utils/push_provider.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/introduction_provider.dart'; -import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/token_folder_provider.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/token_provider.dart'; import 'package:privacyidea_authenticator/utils/rsa_utils.dart'; diff --git a/lib/mains/main_customizer.dart b/lib/mains/main_customizer.dart index cce029bac..3d18ce617 100644 --- a/lib/mains/main_customizer.dart +++ b/lib/mains/main_customizer.dart @@ -27,7 +27,7 @@ import '../l10n/app_localizations.dart'; import '../model/enums/app_feature.dart'; import '../model/riverpod_states/settings_state.dart'; import '../utils/globals.dart'; -import '../utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import '../utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import '../utils/riverpod/riverpod_providers/state_providers/app_constraints_provider.dart'; import '../utils/riverpod/riverpod_providers/state_providers/application_customizer_provider.dart'; import '../views/add_token_manually_view/add_token_manually_view.dart'; diff --git a/lib/mains/main_netknights.dart b/lib/mains/main_netknights.dart index 153ed2bef..1095f66ad 100644 --- a/lib/mains/main_netknights.dart +++ b/lib/mains/main_netknights.dart @@ -32,7 +32,7 @@ import '../utils/customization/application_customization.dart'; import '../utils/globals.dart'; import '../utils/home_widget_utils.dart'; import '../utils/logger.dart'; -import '../utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import '../utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import '../utils/riverpod/riverpod_providers/state_providers/app_constraints_provider.dart'; import '../views/add_token_manually_view/add_token_manually_view.dart'; import '../views/feedback_view/feedback_view.dart'; @@ -89,6 +89,7 @@ class PrivacyIDEAAuthenticator extends ConsumerWidget { ), debugShowCheckedModeBanner: true, navigatorKey: globalNavigatorKey, + localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, locale: ref.watch(settingsProvider).whenOrNull(data: (data) => data.currentLocale) ?? SettingsState.localeDefault, diff --git a/lib/model/extensions/enums/introduction_extension.dart b/lib/model/extensions/enums/introduction_extension.dart index ab10fbcd1..b2741863b 100644 --- a/lib/model/extensions/enums/introduction_extension.dart +++ b/lib/model/extensions/enums/introduction_extension.dart @@ -2,7 +2,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:privacyidea_authenticator/model/riverpod_states/settings_state.dart'; import '../../../l10n/app_localizations.dart'; -import '../../../utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import '../../../utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import '../../../utils/riverpod/riverpod_providers/state_notifier_providers/token_provider.dart'; import '../../enums/introduction.dart'; import '../../riverpod_states/introduction_state.dart'; diff --git a/lib/utils/push_provider.dart b/lib/utils/push_provider.dart index 88891535d..e94ba17d3 100644 --- a/lib/utils/push_provider.dart +++ b/lib/utils/push_provider.dart @@ -37,7 +37,7 @@ import 'firebase_utils.dart'; import 'globals.dart'; import 'logger.dart'; import 'privacyidea_io_client.dart'; -import 'riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import 'riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import 'riverpod/riverpod_providers/state_notifier_providers/token_provider.dart'; import 'riverpod/riverpod_providers/state_providers/status_message_provider.dart'; import 'rsa_utils.dart'; @@ -301,6 +301,8 @@ class PushProvider { final connectivityResult = await (Connectivity().checkConnectivity()); if (connectivityResult.contains(ConnectivityResult.none)) { + + if (isManually) { Logger.info('Tried to poll without any internet connection available.', name: 'push_provider.dart#pollForChallenges'); globalRef?.read(statusMessageProvider.notifier).state = ( diff --git a/lib/utils/riverpod/riverpod_providers/generated_providers/introduction_provider.g.dart b/lib/utils/riverpod/riverpod_providers/generated_providers/introduction_provider.g.dart index bd89c2af3..f1ca78185 100644 --- a/lib/utils/riverpod/riverpod_providers/generated_providers/introduction_provider.g.dart +++ b/lib/utils/riverpod/riverpod_providers/generated_providers/introduction_provider.g.dart @@ -7,7 +7,7 @@ part of 'introduction_provider.dart'; // ************************************************************************** String _$introductionNotifierHash() => - r'2c84c088bf01feb395c187f1671a4c822edf1b42'; + r'ef2eb16345e9723dd63a1c4d4bed72872a447af0'; /// Copied from Dart SDK class _SystemHash { diff --git a/lib/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart b/lib/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart similarity index 99% rename from lib/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart rename to lib/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart index 8af2f8cdb..cefe96492 100644 --- a/lib/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart +++ b/lib/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart @@ -29,7 +29,7 @@ import '../../../../model/riverpod_states/settings_state.dart'; import '../../../../model/version.dart'; import '../../../logger.dart'; -part 'settings_provider.g.dart'; +part 'settings_notifier.g.dart'; final settingsProvider = settingsNotifierProviderOf(repo: PreferenceSettingsRepository()); diff --git a/lib/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.g.dart b/lib/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.g.dart similarity index 97% rename from lib/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.g.dart rename to lib/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.g.dart index baa9f9a01..a8c826024 100644 --- a/lib/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.g.dart +++ b/lib/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.g.dart @@ -1,12 +1,12 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'settings_provider.dart'; +part of 'settings_notifier.dart'; // ************************************************************************** // RiverpodGenerator // ************************************************************************** -String _$settingsNotifierHash() => r'83f54c5fafceae7ace984ef06ac564bee445771f'; +String _$settingsNotifierHash() => r'cbd75880d5ec70ee5910ac34e5c65eb51099b874'; /// Copied from Dart SDK class _SystemHash { diff --git a/lib/utils/riverpod/riverpod_providers/generated_providers/sortable_notifier.dart b/lib/utils/riverpod/riverpod_providers/generated_providers/sortable_notifier.dart new file mode 100644 index 000000000..461a74260 --- /dev/null +++ b/lib/utils/riverpod/riverpod_providers/generated_providers/sortable_notifier.dart @@ -0,0 +1,55 @@ +/* + * privacyIDEA Authenticator + * + * Author: Frank Merkel + * + * Copyright (c) 2024 NetKnights GmbH + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +import 'package:flutter/widgets.dart'; +import 'package:privacyidea_authenticator/model/extensions/sortable_list.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; + +import '../../../../model/mixins/sortable_mixin.dart'; +import '../../../../model/token_folder.dart'; +import '../../../../model/tokens/token.dart'; +import '../state_providers/dragging_sortable_provider.dart'; +import '../state_notifier_providers/token_folder_provider.dart'; +import '../state_notifier_providers/token_provider.dart'; + +part 'sortable_notifier.g.dart'; + +@riverpod +List sortables(SortablesRef ref) { + final tokenFolders = ref.watch(tokenFolderProvider).folders; + final tokens = ref.watch(tokenProvider).tokens; + + var sortablesWithNulls = List.from([...tokens, ...tokenFolders]); + + final sortedSortables = sortablesWithNulls.sorted.fillNullIndices(); + + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + if (sortablesWithNulls.any((e) => e is Token) && sortablesWithNulls.any((element) => element.sortIndex == null)) { + ref.read(tokenProvider.notifier).addOrReplaceTokens(sortedSortables.whereType().toList()); + } + if (sortablesWithNulls.any((e) => e is TokenFolder) && sortablesWithNulls.any((element) => element.sortIndex == null)) { + ref.read(tokenFolderProvider.notifier).addOrReplaceFolders(sortedSortables.whereType().toList()); + } + + ref.read(draggingSortableProvider.notifier).state = null; + }); + + return sortedSortables; +} diff --git a/lib/utils/riverpod/riverpod_providers/generated_providers/sortable_notifier.g.dart b/lib/utils/riverpod/riverpod_providers/generated_providers/sortable_notifier.g.dart new file mode 100644 index 000000000..1e396886d --- /dev/null +++ b/lib/utils/riverpod/riverpod_providers/generated_providers/sortable_notifier.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'sortable_notifier.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$sortablesHash() => r'a4463dc0f1e108f07d4714f0df5f178ef9653f49'; + +/// See also [sortables]. +@ProviderFor(sortables) +final sortablesProvider = AutoDisposeProvider>.internal( + sortables, + name: r'sortablesProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') ? null : _$sortablesHash, + dependencies: null, + allTransitiveDependencies: null, +); + +typedef SortablesRef = AutoDisposeProviderRef>; +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/lib/utils/riverpod/riverpod_providers/state_notifier_providers/sortable_provider.dart b/lib/utils/riverpod/riverpod_providers/state_notifier_providers/sortable_provider.dart deleted file mode 100644 index f40fec012..000000000 --- a/lib/utils/riverpod/riverpod_providers/state_notifier_providers/sortable_provider.dart +++ /dev/null @@ -1,51 +0,0 @@ -/* - * privacyIDEA Authenticator - * - * Author: Frank Merkel - * - * Copyright (c) 2024 NetKnights GmbH - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -import '../../../../model/mixins/sortable_mixin.dart'; -import '../../../../model/riverpod_states/token_folder_state.dart'; -import '../../../../model/riverpod_states/token_state.dart'; -import '../../state_notifiers/sortable_notifier.dart'; -import '../../../logger.dart'; -import 'token_folder_provider.dart'; -import 'token_provider.dart'; - -final sortableProvider = StateNotifierProvider>( - (ref) { - final SortableNotifier notifier = SortableNotifier(ref: ref); - Logger.info("New sortableProvider created", name: 'sortableProvider'); - ref.listen(tokenProvider, (previous, next) => notifier.handleNewStateList(next.tokens)); - ref.listen(tokenFolderProvider, (previous, next) => notifier.handleNewStateList(next.folders)); - Future.wait( - [ref.read(tokenProvider.notifier).initState, ref.read(tokenFolderProvider.notifier).initState], - ).then((values) { - final sortables = []; - for (final v in values) { - if (v is TokenState) { - sortables.addAll(v.tokens); - } else if (v is TokenFolderState) { - sortables.addAll(v.folders); - } - } - notifier.handleNewStateList(sortables); - }); - return notifier; - }, -); diff --git a/lib/utils/riverpod/state_notifiers/sortable_notifier.dart b/lib/utils/riverpod/state_notifiers/sortable_notifier.dart index 463d31936..6451f54ea 100644 --- a/lib/utils/riverpod/state_notifiers/sortable_notifier.dart +++ b/lib/utils/riverpod/state_notifiers/sortable_notifier.dart @@ -1,76 +1,76 @@ -/* - * privacyIDEA Authenticator - * - * Author: Frank Merkel - * - * Copyright (c) 2024 NetKnights GmbH - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import '../../logger.dart'; +// /* +// * privacyIDEA Authenticator +// * +// * Author: Frank Merkel +// * +// * Copyright (c) 2024 NetKnights GmbH +// * +// * Licensed under the Apache License, Version 2.0 (the 'License'); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an 'AS IS' BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ +// import 'package:flutter_riverpod/flutter_riverpod.dart'; +// import '../../logger.dart'; -import '../../../model/extensions/sortable_list.dart'; -import '../../../model/mixins/sortable_mixin.dart'; -import '../../../model/token_folder.dart'; -import '../../../model/tokens/token.dart'; -import '../riverpod_providers/state_notifier_providers/token_folder_provider.dart'; -import '../riverpod_providers/state_notifier_providers/token_provider.dart'; -import '../riverpod_providers/state_providers/dragging_sortable_provider.dart'; +// import '../../../model/extensions/sortable_list.dart'; +// import '../../../model/mixins/sortable_mixin.dart'; +// import '../../../model/token_folder.dart'; +// import '../../../model/tokens/token.dart'; +// import '../riverpod_providers/state_notifier_providers/token_folder_provider.dart'; +// import '../riverpod_providers/state_notifier_providers/token_provider.dart'; +// import '../riverpod_providers/state_providers/dragging_sortable_provider.dart'; -class SortableNotifier extends StateNotifier> { - final StateNotifierProviderRef _ref; - Future>? initState; - SortableNotifier({ - required StateNotifierProviderRef ref, - List initState = const [], - }) : _ref = ref, - super(initState); - Future _waitInit() async { - if (initState != null) { - await initState; - return; - } - initState = Future(() async { - final newSortables = []; - newSortables.addAll((await _ref.read(tokenProvider.notifier).initState).tokens.cast()); - newSortables.addAll((await _ref.read(tokenFolderProvider.notifier).initState).folders.cast()); - state = newSortables.sorted.fillNullIndices(); - return state; - }); - await initState; - } +// // class SortableNotifier extends StateNotifier> { +// // final StateNotifierProviderRef _ref; +// // Future>? initState; +// // SortableNotifier({ +// // required StateNotifierProviderRef ref, +// // List initState = const [], +// // }) : _ref = ref, +// // super(initState); +// // Future _waitInit() async { +// // if (initState != null) { +// // await initState; +// // return; +// // } +// // initState = Future(() async { +// // final newSortables = []; +// // newSortables.addAll((await _ref.read(tokenProvider.notifier).initState).tokens.cast()); +// // newSortables.addAll((await _ref.read(tokenFolderProvider.notifier).initState).folders.cast()); +// // state = newSortables.sorted.fillNullIndices(); +// // return state; +// // }); +// // await initState; +// // } - /// Handles a new list of [T]. - /// First removes all elements of type [T] from the current state and then adds the new list. - Future> handleNewStateList(List newList) async { - Logger.info('Handling new state list of type $T', name: 'SortableNotifier#handleNewStateList'); - await _waitInit(); - var newState = List.from(state); - newState.removeWhere((element) => element is T); - newState.addAll(newList); - final listWithNulls = newState.toList(); - newState = newState.sorted.fillNullIndices(); - state = newState; - await Future.wait([ - Future.delayed(const Duration(milliseconds: 50)), - if (listWithNulls.any((e) => e is Token) && listWithNulls.any((element) => element.sortIndex == null)) - _ref.read(tokenProvider.notifier).addOrReplaceTokens(state.whereType().toList()), - if (listWithNulls.any((e) => e is TokenFolder) && listWithNulls.any((element) => element.sortIndex == null)) - _ref.read(tokenFolderProvider.notifier).addOrReplaceFolders(state.whereType().toList()), - ]); +// // /// Handles a new list of [T]. +// // /// First removes all elements of type [T] from the current state and then adds the new list. +// // Future> handleNewStateList(List newList) async { +// // Logger.info('Handling new state list of type $T', name: 'SortableNotifier#handleNewStateList'); +// // await _waitInit(); +// // var newState = List.from(state); +// // newState.removeWhere((element) => element is T); +// // newState.addAll(newList); +// // final listWithNulls = newState.toList(); +// // newState = newState.sorted.fillNullIndices(); +// // state = newState; +// // await Future.wait([ +// // Future.delayed(const Duration(milliseconds: 50)), +// // if (listWithNulls.any((e) => e is Token) && listWithNulls.any((element) => element.sortIndex == null)) +// // _ref.read(tokenProvider.notifier).addOrReplaceTokens(state.whereType().toList()), +// // if (listWithNulls.any((e) => e is TokenFolder) && listWithNulls.any((element) => element.sortIndex == null)) +// // _ref.read(tokenFolderProvider.notifier).addOrReplaceFolders(state.whereType().toList()), +// // ]); - _ref.read(draggingSortableProvider.notifier).state = null; - return newState; - } -} +// // _ref.read(draggingSortableProvider.notifier).state = null; +// // return newState; +// // } +// // } diff --git a/lib/utils/riverpod/state_notifiers/token_notifier.dart b/lib/utils/riverpod/state_notifiers/token_notifier.dart index a6c156ef1..b661c82e8 100644 --- a/lib/utils/riverpod/state_notifiers/token_notifier.dart +++ b/lib/utils/riverpod/state_notifiers/token_notifier.dart @@ -53,7 +53,7 @@ import '../../identifiers.dart'; import '../../lock_auth.dart'; import '../../logger.dart'; import '../../privacyidea_io_client.dart'; -import '../riverpod_providers/state_notifier_providers/settings_provider.dart'; +import '../riverpod_providers/generated_providers/settings_notifier.dart'; import '../riverpod_providers/state_providers/status_message_provider.dart'; import '../../rsa_utils.dart'; import '../../utils.dart'; diff --git a/lib/views/main_view/main_view.dart b/lib/views/main_view/main_view.dart index 3f0abc27b..5f6b1c8f7 100644 --- a/lib/views/main_view/main_view.dart +++ b/lib/views/main_view/main_view.dart @@ -25,7 +25,7 @@ import '../../model/riverpod_states/token_filter.dart'; import '../../utils/globals.dart'; import '../../utils/logger.dart'; import '../../utils/patch_notes_utils.dart'; -import '../../utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import '../../utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import '../../utils/riverpod/riverpod_providers/state_providers/token_filter_provider.dart'; import '../../widgets/push_request_listener.dart'; import '../../widgets/status_bar.dart'; diff --git a/lib/views/main_view/main_view_widgets/folder_widgets/token_folder_expandable.dart b/lib/views/main_view/main_view_widgets/folder_widgets/token_folder_expandable.dart index 236c655bb..44fee270d 100644 --- a/lib/views/main_view/main_view_widgets/folder_widgets/token_folder_expandable.dart +++ b/lib/views/main_view/main_view_widgets/folder_widgets/token_folder_expandable.dart @@ -35,7 +35,7 @@ import '../../../../model/tokens/token.dart'; import '../../../../utils/customization/action_theme.dart'; import '../../../../utils/globals.dart'; import '../../../../utils/lock_auth.dart'; -import '../../../../utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import '../../../../utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import '../../../../utils/riverpod/riverpod_providers/state_notifier_providers/token_folder_provider.dart'; import '../../../../utils/riverpod/riverpod_providers/state_notifier_providers/token_provider.dart'; import '../../../../utils/riverpod/riverpod_providers/state_providers/dragging_sortable_provider.dart'; diff --git a/lib/views/main_view/main_view_widgets/main_view_navigation_buttons/license_push_view_button.dart b/lib/views/main_view/main_view_widgets/main_view_navigation_buttons/license_push_view_button.dart index e91ecfc0c..8ebef959d 100644 --- a/lib/views/main_view/main_view_widgets/main_view_navigation_buttons/license_push_view_button.dart +++ b/lib/views/main_view/main_view_widgets/main_view_navigation_buttons/license_push_view_button.dart @@ -24,7 +24,7 @@ import 'package:privacyidea_authenticator/model/riverpod_states/settings_state.d import '../../../../l10n/app_localizations.dart'; import '../../../../model/enums/introduction.dart'; import '../../../../utils/riverpod/riverpod_providers/generated_providers/introduction_provider.dart'; -import '../../../../utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import '../../../../utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import '../../../../widgets/focused_item_as_overlay.dart'; import '../../../license_view/license_view.dart'; import '../../../push_token_view/push_tokens_view.dart'; diff --git a/lib/views/main_view/main_view_widgets/main_view_tokens_list.dart b/lib/views/main_view/main_view_widgets/main_view_tokens_list.dart index a52021f50..64ff25f71 100644 --- a/lib/views/main_view/main_view_widgets/main_view_tokens_list.dart +++ b/lib/views/main_view/main_view_widgets/main_view_tokens_list.dart @@ -27,8 +27,8 @@ import '../../../model/riverpod_states/settings_state.dart'; import '../../../model/token_folder.dart'; import '../../../model/tokens/push_token.dart'; import '../../../model/tokens/token.dart'; -import '../../../utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; -import '../../../utils/riverpod/riverpod_providers/state_notifier_providers/sortable_provider.dart'; +import '../../../utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; +import '../../../utils/riverpod/riverpod_providers/generated_providers/sortable_notifier.dart'; import '../../../utils/riverpod/riverpod_providers/state_providers/dragging_sortable_provider.dart'; import '../../../widgets/default_refresh_indicator.dart'; import '../../../widgets/drag_item_scroller.dart'; @@ -83,7 +83,7 @@ class _MainViewTokensListState extends ConsumerState { @override Widget build(BuildContext context) { final draggingSortable = ref.watch(draggingSortableProvider); - final allSortables = ref.watch(sortableProvider); + final allSortables = ref.watch(sortablesProvider); final allowToRefresh = allSortables.any((element) => element is PushToken); final hidePushTokens = ref.watch(settingsProvider).whenOrNull(data: (data) => data.hidePushTokens) ?? SettingsState.hidePushTokensDefault; final filterPushTokens = hidePushTokens && allowToRefresh; diff --git a/lib/views/main_view/main_view_widgets/token_widgets/day_password_token_widgets/day_password_token_widget_tile.dart b/lib/views/main_view/main_view_widgets/token_widgets/day_password_token_widgets/day_password_token_widget_tile.dart index e865a3e93..49df7c308 100644 --- a/lib/views/main_view/main_view_widgets/token_widgets/day_password_token_widgets/day_password_token_widget_tile.dart +++ b/lib/views/main_view/main_view_widgets/token_widgets/day_password_token_widgets/day_password_token_widget_tile.dart @@ -28,7 +28,7 @@ import '../../../../../l10n/app_localizations.dart'; import '../../../../../model/enums/day_password_token_view_mode.dart'; import '../../../../../model/riverpod_states/settings_state.dart'; import '../../../../../model/tokens/day_password_token.dart'; -import '../../../../../utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import '../../../../../utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import '../../../../../utils/riverpod/riverpod_providers/state_notifier_providers/token_provider.dart'; import '../../../../../utils/utils.dart'; import '../../../../../widgets/custom_texts.dart'; diff --git a/lib/views/settings_view/settings_groups/settings_group_language.dart b/lib/views/settings_view/settings_groups/settings_group_language.dart index fbac7c690..775a7bcc9 100644 --- a/lib/views/settings_view/settings_groups/settings_group_language.dart +++ b/lib/views/settings_view/settings_groups/settings_group_language.dart @@ -22,7 +22,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:privacyidea_authenticator/model/riverpod_states/settings_state.dart'; import '../../../l10n/app_localizations.dart'; -import '../../../utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import '../../../utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import '../settings_view_widgets/settings_groups.dart'; class SettingsGroupLanguage extends ConsumerWidget { diff --git a/lib/views/settings_view/settings_groups/settings_group_push_token.dart b/lib/views/settings_view/settings_groups/settings_group_push_token.dart index 416323bb9..ece20c1cf 100644 --- a/lib/views/settings_view/settings_groups/settings_group_push_token.dart +++ b/lib/views/settings_view/settings_groups/settings_group_push_token.dart @@ -23,7 +23,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../../l10n/app_localizations.dart'; import '../../../model/riverpod_states/settings_state.dart'; import '../../../model/tokens/push_token.dart'; -import '../../../utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import '../../../utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import '../../../utils/riverpod/riverpod_providers/state_notifier_providers/token_provider.dart'; import '../settings_view_widgets/settings_groups.dart'; import '../settings_view_widgets/update_firebase_token_dialog.dart'; diff --git a/lib/views/settings_view/settings_view_widgets/logging_menu.dart b/lib/views/settings_view/settings_view_widgets/logging_menu.dart index f0f5392bf..3505f9c69 100644 --- a/lib/views/settings_view/settings_view_widgets/logging_menu.dart +++ b/lib/views/settings_view/settings_view_widgets/logging_menu.dart @@ -22,7 +22,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:privacyidea_authenticator/model/riverpod_states/settings_state.dart'; import '../../../l10n/app_localizations.dart'; -import '../../../utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import '../../../utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import '../../../widgets/dialog_widgets/default_dialog.dart'; import 'errorlog_buttons/delete_errorlog_button.dart'; import 'errorlog_buttons/send_errorlog_button.dart'; diff --git a/lib/widgets/dialog_widgets/patch_notes_dialog.dart b/lib/widgets/dialog_widgets/patch_notes_dialog.dart index 0f8c3d232..13358f5a7 100644 --- a/lib/widgets/dialog_widgets/patch_notes_dialog.dart +++ b/lib/widgets/dialog_widgets/patch_notes_dialog.dart @@ -8,7 +8,7 @@ import '../../model/extensions/enums/patch_note_type_extension.dart'; import '../../model/version.dart'; import '../../utils/app_info_utils.dart'; import '../../utils/globals.dart'; -import '../../utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import '../../utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import 'default_dialog.dart'; class PatchNotesDialog extends StatelessWidget { diff --git a/test/unit_test/state_notifiers/settings_notifier_test.dart b/test/unit_test/state_notifiers/settings_notifier_test.dart index c88daa3fa..1896107f4 100644 --- a/test/unit_test/state_notifiers/settings_notifier_test.dart +++ b/test/unit_test/state_notifiers/settings_notifier_test.dart @@ -4,7 +4,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import 'package:privacyidea_authenticator/model/riverpod_states/settings_state.dart'; -import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import '../../tests_app_wrapper.mocks.dart'; diff --git a/test/unit_test/state_notifiers/sortable_notifier_test.dart b/test/unit_test/state_notifiers/sortable_notifier_test.dart index 142bbeacc..6ce698b82 100644 --- a/test/unit_test/state_notifiers/sortable_notifier_test.dart +++ b/test/unit_test/state_notifiers/sortable_notifier_test.dart @@ -7,11 +7,10 @@ import 'package:privacyidea_authenticator/model/token_folder.dart'; import 'package:privacyidea_authenticator/model/tokens/hotp_token.dart'; import 'package:privacyidea_authenticator/model/tokens/token.dart'; import 'package:privacyidea_authenticator/model/tokens/totp_token.dart'; -import 'package:privacyidea_authenticator/utils/riverpod/state_notifiers/sortable_notifier.dart'; +import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/sortable_notifier.dart'; import 'package:privacyidea_authenticator/utils/riverpod/state_notifiers/token_folder_notifier.dart'; import 'package:privacyidea_authenticator/utils/riverpod/state_notifiers/token_notifier.dart'; -import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; -import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/sortable_provider.dart'; +import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/token_folder_provider.dart'; import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/token_provider.dart'; @@ -62,15 +61,10 @@ void _testSortableNotifier() { tokenProvider.overrideWith((ref) => TokenNotifier(repository: mockTokenRepository, ref: ref)), ]); - final SortableNotifier sortableNotifier = container.read(sortableProvider.notifier); - final newToken = TOTPToken(period: 30, id: 'Token 4', algorithm: Algorithms.SHA1, digits: 6, secret: 'secret4', folderId: 1, sortIndex: 1); + await container.read(tokenProvider.notifier).addNewToken(newToken); + final newSortableState = container.read(sortablesProvider); - final newTokenState = tokenState.toList()..add(newToken); - final newState = await sortableNotifier.handleNewStateList(newTokenState); - - final newSortableState = container.read(sortableProvider); - expect(newState.length, 6); expect(newSortableState.length, 6); expect(newSortableState[0], isA()); expect((newSortableState[0] as Token).id, 'Token 3'); diff --git a/test/unit_test/state_notifiers/token_notifier_test.dart b/test/unit_test/state_notifiers/token_notifier_test.dart index bc9428c8a..fd9ec01b4 100644 --- a/test/unit_test/state_notifiers/token_notifier_test.dart +++ b/test/unit_test/state_notifiers/token_notifier_test.dart @@ -14,7 +14,7 @@ import 'package:privacyidea_authenticator/model/tokens/push_token.dart'; import 'package:privacyidea_authenticator/model/tokens/token.dart'; import 'package:privacyidea_authenticator/utils/riverpod/state_notifiers/token_notifier.dart'; import 'package:privacyidea_authenticator/utils/logger.dart'; -import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/state_notifier_providers/settings_provider.dart'; +import 'package:privacyidea_authenticator/utils/riverpod/riverpod_providers/generated_providers/settings_notifier.dart'; import 'package:privacyidea_authenticator/utils/rsa_utils.dart'; import '../../tests_app_wrapper.mocks.dart';