Skip to content

TW-2928 Reorder contacts list#2929

Open
tddang-linagora wants to merge 1 commit intosprint/march26from
TW-2928/Reorder-contacts-list
Open

TW-2928 Reorder contacts list#2929
tddang-linagora wants to merge 1 commit intosprint/march26from
TW-2928/Reorder-contacts-list

Conversation

@tddang-linagora
Copy link
Collaborator

@tddang-linagora tddang-linagora commented Mar 17, 2026

Ticket

Resolved

contact.mp4

Summary by CodeRabbit

  • Refactor
    • Restructured the contacts tab interface by extracting UI components into discrete, reusable modules for improved maintainability and code organization. Components now include separate handlers for loading states, recent contacts, contacts with and without identifiers, phonebook entries, and empty states.

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3963e097-bd80-41c8-ab41-de997e9f4272

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch TW-2928/Reorder-contacts-list
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes.

Add @coderabbitai placeholder anywhere in the title of your PR and CodeRabbit will replace it with a title based on the changes in the PR. You can change the placeholder by changing the reviews.auto_title_placeholder setting.

@github-actions
Copy link
Contributor

This PR has been deployed to https://linagora.github.io/twake-on-matrix/2929

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
lib/pages/contacts_tab/widgets/sliver_contacts_with_matrix_id.dart (1)

67-119: Consider unifying duplicated contact-tile implementations.

_ExternalContactTile and _ContactTile duplicate the same tile configuration; only sliver wrapping differs. Consolidating this reduces maintenance drift.

♻️ Proposed refactor
-class _ExternalContactTile extends StatelessWidget {
-  const _ExternalContactTile({required this.controller, required this.contact});
+class _ContactTile extends StatelessWidget {
+  const _ContactTile({
+    required this.contact,
+    required this.controller,
+    this.wrapWithSliver = false,
+  });

-  final ContactsTabController controller;
   final PresentationContact contact;
+  final ContactsTabController controller;
+  final bool wrapWithSliver;

   `@override`
   Widget build(BuildContext context) {
-    return SliverToBoxAdapter(
-      child: Padding(
-        padding: const EdgeInsets.symmetric(
-          horizontal: ContactsTabViewStyle.padding,
-        ),
-        child: ExpansionContactListTile(
-          contact: contact,
-          highlightKeyword: controller.textEditingController.text,
-          enableInvitation: controller.supportInvitation(),
-          onContactTap: () => controller.onContactTap(
-            context: context,
-            path: 'rooms',
-            contact: contact,
-          ),
-        ),
-      ),
-    );
+    final tile = Padding(
+      padding: const EdgeInsets.symmetric(horizontal: ContactsTabViewStyle.padding),
+      child: ExpansionContactListTile(
+        contact: contact,
+        highlightKeyword: controller.textEditingController.text,
+        enableInvitation: controller.supportInvitation(),
+        onContactTap: () => controller.onContactTap(
+          context: context,
+          path: 'rooms',
+          contact: contact,
+        ),
+      ),
+    );
+    return wrapWithSliver ? SliverToBoxAdapter(child: tile) : tile;
   }
 }
-            return _ExternalContactTile(
+            return _ContactTile(
               controller: controller,
               contact: success.contact,
+              wrapWithSliver: true,
             );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/pages/contacts_tab/widgets/sliver_contacts_with_matrix_id.dart` around
lines 67 - 119, Both _ExternalContactTile and _ContactTile duplicate the same
ExpansionContactListTile configuration; refactor by creating a single reusable
widget (e.g., ContactTile or ContactTileWrapper) that accepts the same
PresentationContact and ContactsTabController props plus a flag or enum (e.g.,
bool asSliver) to decide whether to wrap the tile in SliverToBoxAdapter. Move
the shared ExpansionContactListTile construction (including highlightKeyword,
enableInvitation, and onContactTap usage) into that single widget and replace
both _ExternalContactTile and _ContactTile usages with the new widget, passing
asSliver=true for the sliver case and false for the regular case so behavior
remains identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/pages/contacts_tab/widgets/sliver_empty_contacts.dart`:
- Around line 14-17: Update the _isLoading function so it also returns true
while the phonebook data is loading to avoid showing
EmptyContactBody/NoContactsFound prematurely; specifically, inside _isLoading
(which currently checks controller.presentationContactNotifier for
ContactsLoading), also check the controller's phonebook loading notifier/state
(e.g. controller.phonebookNotifier or controller.phonebookState) and return true
if that notifier indicates a loading state, combining the two checks so either
presentationContactNotifier is ContactsLoading OR the phonebook notifier is
loading.

---

Nitpick comments:
In `@lib/pages/contacts_tab/widgets/sliver_contacts_with_matrix_id.dart`:
- Around line 67-119: Both _ExternalContactTile and _ContactTile duplicate the
same ExpansionContactListTile configuration; refactor by creating a single
reusable widget (e.g., ContactTile or ContactTileWrapper) that accepts the same
PresentationContact and ContactsTabController props plus a flag or enum (e.g.,
bool asSliver) to decide whether to wrap the tile in SliverToBoxAdapter. Move
the shared ExpansionContactListTile construction (including highlightKeyword,
enableInvitation, and onContactTap usage) into that single widget and replace
both _ExternalContactTile and _ContactTile usages with the new widget, passing
asSliver=true for the sliver case and false for the regular case so behavior
remains identical.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: edd66a26-a6bd-4395-8411-4bc18dbab4ca

📥 Commits

Reviewing files that changed from the base of the PR and between 574496c and 2d8b637.

📒 Files selected for processing (9)
  • lib/pages/contacts_tab/contacts_tab_body_view.dart
  • lib/pages/contacts_tab/widgets/sliver_contacts_with_matrix_id.dart
  • lib/pages/contacts_tab/widgets/sliver_contacts_without_matrix_id.dart
  • lib/pages/contacts_tab/widgets/sliver_empty_contacts.dart
  • lib/pages/contacts_tab/widgets/sliver_loading_contacts.dart
  • lib/pages/contacts_tab/widgets/sliver_phonebook_contacts_with_matrix_id.dart
  • lib/pages/contacts_tab/widgets/sliver_phonebook_contacts_without_matrix_id.dart
  • lib/pages/contacts_tab/widgets/sliver_recent_contacts.dart
  • lib/pages/contacts_tab/widgets/sliver_warning_banner.dart

Comment on lines +14 to +17
bool _isLoading() => controller.presentationContactNotifier.value.fold(
(_) => false,
(s) => s is ContactsLoading,
);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Include phonebook loading in _isLoading to prevent premature empty-state rendering.

Right now, loading is inferred only from presentationContactNotifier. When phonebook data is still loading, the widget can briefly show EmptyContactBody / NoContactsFound before data arrives.

🐛 Proposed fix
-  bool _isLoading() => controller.presentationContactNotifier.value.fold(
-    (_) => false,
-    (s) => s is ContactsLoading,
-  );
+  bool _isLoading() {
+    final contactsLoading = controller.presentationContactNotifier.value.fold(
+      (_) => false,
+      (s) => s is ContactsLoading,
+    );
+    final phonebookLoading =
+        controller.presentationPhonebookContactNotifier.value.fold(
+          (_) => false,
+          (s) => s is ContactsLoading,
+        );
+    return contactsLoading || phonebookLoading;
+  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/pages/contacts_tab/widgets/sliver_empty_contacts.dart` around lines 14 -
17, Update the _isLoading function so it also returns true while the phonebook
data is loading to avoid showing EmptyContactBody/NoContactsFound prematurely;
specifically, inside _isLoading (which currently checks
controller.presentationContactNotifier for ContactsLoading), also check the
controller's phonebook loading notifier/state (e.g. controller.phonebookNotifier
or controller.phonebookState) and return true if that notifier indicates a
loading state, combining the two checks so either presentationContactNotifier is
ContactsLoading OR the phonebook notifier is loading.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant