Skip to content

Conversation

@guillaumetavernier
Copy link
Contributor

@guillaumetavernier guillaumetavernier commented Jun 9, 2025

Full refacto of app routing

@codecov-commenter
Copy link

codecov-commenter commented Jun 9, 2025

Codecov Report

Attention: Patch coverage is 14.28571% with 306 lines in your changes missing coverage. Please review.

Project coverage is 55.86%. Comparing base (ecfac07) to head (8e86bc5).

Files with missing lines Patch % Lines
lib/auth/providers/openid_provider.dart 30.00% 84 Missing ⚠️
lib/tools/repository/repository.dart 0.00% 75 Missing ⚠️
lib/auth/class/auth_request.dart 4.16% 23 Missing ⚠️
lib/tools/token_expire_wrapper.dart 0.00% 18 Missing ⚠️
lib/auth/class/auth_token.dart 40.00% 15 Missing ⚠️
lib/tools/functions.dart 0.00% 8 Missing ⚠️
lib/auth/repository/openid_repository.dart 0.00% 7 Missing ⚠️
lib/tools/providers/map_provider.dart 0.00% 6 Missing ⚠️
lib/version/repositories/version_repository.dart 0.00% 3 Missing ⚠️
lib/admin/providers/group_logo_provider.dart 0.00% 2 Missing ⚠️
... and 35 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #561      +/-   ##
==========================================
+ Coverage   54.29%   55.86%   +1.56%     
==========================================
  Files         169      170       +1     
  Lines        3702     3693       -9     
==========================================
+ Hits         2010     2063      +53     
+ Misses       1692     1630      -62     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@guillaumetavernier guillaumetavernier changed the base branch from main to repo-refacto June 9, 2025 20:10
@guillaumetavernier guillaumetavernier changed the base branch from repo-refacto to main June 14, 2025 15:22
@guillaumetavernier guillaumetavernier changed the title Improvement on router when refreshing on web Big revamp: Auth/Repository/Router Jun 14, 2025
@guillaumetavernier guillaumetavernier force-pushed the improve-router branch 2 times, most recently from 4c8b9d3 to 3606c7b Compare June 14, 2025 15:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a major refactor of the authentication, repository, and routing logic in the administration module by removing the usage of the tokenExpireWrapper, updating repository constructors to accept the provider reference, and cleaning up unused imports.

  • Removed tokenExpireWrapper calls from multiple UI pages to simplify asynchronous workflows.
  • Updated repository instantiations to use dependency injection via constructor parameters.
  • Removed outdated token management imports that are no longer needed.

Reviewed Changes

Copilot reviewed 261 out of 261 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/admin/ui/pages/memberships/association_membership_detail_page/association_membership_information_editor.dart Removed tokenExpireWrapper call from updateAssociationMembership process.
lib/admin/ui/pages/memberships/add_edit_user_membership_page/add_edit_user_membership_page.dart Removed tokenExpireWrapper wrapping for user queries and group updates.
lib/admin/ui/pages/groups/group_page/group_page.dart Removed tokenExpireWrapper call from group deletion confirmation.
lib/admin/ui/pages/groups/edit_group_page/search_user.dart Removed tokenExpireWrapper in the remove group member callback.
lib/admin/ui/pages/groups/edit_group_page/edit_group_page.dart Removed tokenExpireWrapper call from group update process.
lib/admin/ui/pages/groups/add_loaner_page/add_loaner_page.dart Removed tokenExpireWrapper call in the onTap callback for adding loaners.
lib/admin/ui/pages/groups/add_group_page/add_group_page.dart Removed tokenExpireWrapper call during group creation.
lib/admin/ui/pages/add_edit_structure_page/add_edit_structure_page.dart Removed tokenExpireWrapper call during structure update/creation.
lib/admin/ui/admin.dart Removed tokenExpireWrapper call from the onMenu callback in the top bar.
(Various repository and provider files) Updated repository constructors to accept ref and set tokens, and removed obsolete tokenExpireWrapper imports.
Comments suppressed due to low confidence (2)

lib/admin/ui/pages/memberships/association_membership_detail_page/association_membership_information_editor.dart:123

  • Ensure that token expiration handling is appropriately maintained after removing the tokenExpireWrapper call in the update flow. If a new pattern is being adopted, verify that it covers all necessary error and token refresh scenarios.
await tokenExpireWrapper(ref, () async {

lib/admin/ui/pages/memberships/add_edit_user_membership_page/add_edit_user_membership_page.dart:61

  • Review the removal of tokenExpireWrapper in the asynchronous onChanged and group update callbacks to ensure that token expiration and error handling is still effectively managed by the new approach.
tokenExpireWrapper(ref, () async {

Comment on lines 25 to 29
final forwardedFrom =
QR.params[forwardedFromKey]?.toString() ?? AppRouter.root;
final redirectPath = ref.watch(
authRedirectServiceProvider.select(
(service) => service.getRedirect(forwardedFrom),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The service should take QR.currentPath instead

Suggested change
final forwardedFrom =
QR.params[forwardedFromKey]?.toString() ?? AppRouter.root;
final redirectPath = ref.watch(
authRedirectServiceProvider.select(
(service) => service.getRedirect(forwardedFrom),
final redirectPath = ref.watch(
authRedirectServiceProvider.select(
(service) => service.getRedirect(QR.currentPath),

QR.to(pathForwarding.path);
QR.to(
QR.params['forwardedFrom']
?.toString() ??
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the redirect service and do not access 'forwardedFrom' directly

final forwardedFrom =
QR.params[forwardedFromKey]?.toString() ?? AppRouter.root;

final redirectPath = ref.watch(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that


if (redirectPath != null &&
Uri.parse(redirectPath).path != AppRouter.loading) {
Future.microtask(() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check that

QR.params[forwardedFromKey]?.toString() ?? AppRouter.root;
final redirectPath = ref.watch(
authRedirectServiceProvider.select(
(service) => service.getRedirect(forwardedFrom),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

TypeMsg.msg,
SeedLibraryTextConstants.addedSpecies,
SeedLibraryTextConstants.updatedSpecies,
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not touch that

Comment on lines +517 to +528

void removeQueryParam(String keyToRemove) {
final params = QR.params.asMap;
params.remove(keyToRemove);
QR.params.updateParams(QParams(params: params));
}

void addQueryParam(String key, String value) {
final params = QR.params.asMap;
params[key] = ParamValue(value, keepAlive: true);
QR.params.updateParams(QParams(params: params));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be cleaned up

setTData(t, AsyncData([value]));
}
});
loader(t).then((value) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably what caused the bug with autoloader (fixed)

loader == null
? notifier.autoLoadList(ref, mapKey, listLoader!)
: notifier.autoLoad(ref, mapKey, loader!);
Future(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix a bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants