Skip to content

Commit

Permalink
Go to error when not able to connect
Browse files Browse the repository at this point in the history
  • Loading branch information
gabber235 committed Nov 26, 2023
1 parent 2a2a644 commit 00d8cbd
Show file tree
Hide file tree
Showing 65 changed files with 3,240 additions and 1,297 deletions.
21 changes: 12 additions & 9 deletions app/lib/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class AppRouter extends _$AppRouter {

@override
RouteType get defaultRouteType => const RouteType.custom(
transitionsBuilder: TransitionsBuilders.noTransition);
transitionsBuilder: TransitionsBuilders.noTransition,
);

@override
List<AutoRoute> get routes => [
Expand Down Expand Up @@ -65,12 +66,12 @@ RouteData? _fetchCurrentRouteData(String name, RoutingController controller) {

/// Provides the current route data for the given [name].
@Riverpod(keepAlive: true)
RouteData? currentRouteData(CurrentRouteDataRef ref, String name) {
RouteData? currentRouteData(CurrentRouteDataRef ref, String path) {
final router = ref.watch(appRouter);
void invalidator() => ref.invalidateSelf();
router.addListener(invalidator);
ref.onDispose(() => router.removeListener(invalidator));
return _fetchCurrentRouteData(name, router);
return _fetchCurrentRouteData(path, router);
}

extension AppRouterX on AppRouter {
Expand All @@ -89,15 +90,17 @@ extension AppRouterX on AppRouter {
}
}

/// Navigate to the given [pageId].
/// Navigate to the given [pageName].
/// Returns true if the page was changed.
Future<void> navigateToPage(PassingRef ref, String pageId) async {
Future<void> navigateToPage(PassingRef ref, String pageName) async {
final currentPage = ref.read(currentPageProvider);

if (currentPage?.name != pageId) {
await ref.read(appRouter).push(PageEditorRoute(id: pageId),
onFailure: (e) =>
debugPrint("Failed to navigate to page $pageId: $e"));
if (currentPage?.pageName != pageName) {
await ref.read(appRouter).push(
PageEditorRoute(id: pageName),
onFailure: (e) =>
debugPrint("Failed to navigate to page $pageName: $e"),
);
}
}
}
73 changes: 59 additions & 14 deletions app/lib/app_router.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 5 additions & 45 deletions app/lib/app_router.gr.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 17 additions & 12 deletions app/lib/models/adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,41 @@ List<Adapter> adapters(AdaptersRef ref) => ref.watch(bookProvider).adapters;
List<EntryBlueprint> entryBlueprints(EntryBlueprintsRef ref) =>
ref.watch(adaptersProvider).expand((e) => e.entries).toList();

/// A generated provider to fetch and cache a specific [EntryBlueprint] by its [name].
/// A generated provider to fetch and cache a specific [EntryBlueprint] by its [blueprintName].
@riverpod
EntryBlueprint? entryBlueprint(EntryBlueprintRef ref, String name) =>
ref.watch(entryBlueprintsProvider).firstWhereOrNull((e) => e.name == name);
EntryBlueprint? entryBlueprint(EntryBlueprintRef ref, String blueprintName) =>
ref
.watch(entryBlueprintsProvider)
.firstWhereOrNull((e) => e.name == blueprintName);

@riverpod
List<String> entryTags(EntryTagsRef ref, String name) =>
ref.watch(entryBlueprintProvider(name))?.tags ?? [];
List<String> entryTags(EntryTagsRef ref, String blueprintName) =>
ref.watch(entryBlueprintProvider(blueprintName))?.tags ?? [];

/// Gets all the modifiers with a given name.
@riverpod
Map<String, Modifier> fieldModifiers(
FieldModifiersRef ref,
String blueprint,
String name,
String blueprintName,
String modifierName,
) {
return ref
.watch(entryBlueprintProvider(blueprint))
?.fieldsWithModifier(name) ??
.watch(entryBlueprintProvider(blueprintName))
?.fieldsWithModifier(modifierName) ??
{};
}

/// Gets all the paths from fields with a given modifier.
@riverpod
List<String> modifierPaths(
ModifierPathsRef ref,
String blueprint,
String name,
String blueprintName,
String modifierName,
) {
return ref.watch(fieldModifiersProvider(blueprint, name)).keys.toList();
return ref
.watch(fieldModifiersProvider(blueprintName, modifierName))
.keys
.toList();
}

/// A data model that represents an adapter.
Expand Down
Loading

0 comments on commit 00d8cbd

Please sign in to comment.