Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: unify and simplify conversation lists [WPB-9433] #3480

Merged
merged 6 commits into from
Oct 2, 2024

Conversation

saleniuk
Copy link
Contributor

@saleniuk saleniuk commented Oct 1, 2024

StoryWPB-9433 [Android] Implement Pagination for Conversation Screen Data Retrieval


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

Conversation list composables are overly complicated and have many leftovers after bottom tabs and multiple refactors, so in order to implement pagination, it's better to first make a cleanup.

Solutions

  • removed all legacy code related to bottom tabs
  • simplified naming and code of conversation-list-related screens and removed complicated “routers” or “bridges”, now ConversationsScreenContent is a composable used to create screens with conversation lists
  • removed unneeded ConversationItemType from ConversationRouterState, extracted it into dedicated file and renamed to ConversationsDialogsState as from now on it only contains conversation-list-related dialogs states
  • combined conversationSearchResult and foldersWithConversations into single one as having two separate fields is not necessary and actually would complicate it even more when implementing pagination
  • removed duplicated and unused code leftover from previous refactors and updated ConversationListViewModel to use AssistedInject and thanks to that reduced the number of functions and LaunchedEffects needed
  • created interfaces for ConversationListViewModel and ConversationCallListViewModel and “Preview” versions of them to be able to create previews for screens that show conversation list and use ConversationsScreenContent
  • added previews for conversation list composable, all conversations screen and archive screen
  • extracted empty screens to dedicated files (search, archive and all conversations)
  • changed parameter from Activity to Context for functions that return call intents, to be able to show previews (there is no Activity for composable previews)
  • updated tests, refactored to have Arrangement classes

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

How to Test

Open all conversations list or archive list and make sure everything works as it should.


PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

Copy link

Ups 🫰🟨

This PR is too big. Please try to break it up into smaller PRs.

@echoes-hq echoes-hq bot added the echoes: technical-roadmap Work contributing to the Technical Roadmap, to improve our velocity or reduce the technical debt. label Oct 1, 2024
@saleniuk saleniuk changed the title Refactor/unify and simplify conversation lists refactor: unify and simplify conversation lists [WPB-9433] Oct 1, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 43.95604% with 51 lines in your changes missing coverage. Please review.

Project coverage is 44.46%. Comparing base (864094a) to head (07e0f9f).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...ome/conversationslist/ConversationListViewModel.kt 47.14% 33 Missing and 4 partials ⚠️
...ome/conversationslist/ConversationsDialogsState.kt 0.00% 8 Missing ⚠️
...conversationslist/ConversationCallListViewModel.kt 60.00% 4 Missing ⚠️
...om/wire/android/ui/calling/StartingCallActivity.kt 0.00% 1 Missing ⚠️
.../android/ui/calling/ongoing/OngoingCallActivity.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3480      +/-   ##
===========================================
- Coverage    44.59%   44.46%   -0.13%     
===========================================
  Files          467      466       -1     
  Lines        15785    15737      -48     
  Branches      2656     2652       -4     
===========================================
- Hits          7039     6998      -41     
+ Misses        7989     7982       -7     
  Partials       757      757              
Files with missing lines Coverage Δ
...ui/home/conversationslist/ConversationListState.kt 100.00% <ø> (ø)
...ome/conversationslist/model/ConversationsSource.kt 100.00% <100.00%> (ø)
...om/wire/android/ui/calling/StartingCallActivity.kt 0.00% <0.00%> (ø)
.../android/ui/calling/ongoing/OngoingCallActivity.kt 0.00% <0.00%> (ø)
...conversationslist/ConversationCallListViewModel.kt 77.41% <60.00%> (+10.75%) ⬆️
...ome/conversationslist/ConversationsDialogsState.kt 0.00% <0.00%> (ø)
...ome/conversationslist/ConversationListViewModel.kt 49.65% <47.14%> (-6.33%) ⬇️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 864094a...07e0f9f. Read the comment docs.

Copy link
Contributor

@yamilmedina yamilmedina left a comment

Choose a reason for hiding this comment

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

Looks good to me! Before adding the ✅ What about adding ADR? since we are refactoring and removing lots of code (👏 ) and unifying to new ones (🙌 )

@AndroidBob
Copy link
Collaborator

New ADR(s) in this PR 📚:

5. Conversation list composables refactor

Date: 2024-10-01

Status

Accepted

Context

Conversation-list-related composables and screens (all conversations, archive) are overly
complicated and have many leftovers after bottom tabs and multiple refactors,
so in order to implement pagination, it's better to make a cleanup first.

Decision

Simplify and unify composables related to creating screens that show conversation lists.
Remove old, unused code, like things that were implemented in order to make the bottom tabs or code
leftover from previous refactors, and update to make it more readable, reusable and maintainable.
Make it more similar to what we have in other places - instead of having complicated "routers" or
"bridges", just create "content" composable that can be used on multiple screens,
but with the intention that common ViewModels are incorporated into this content composable,
so that they do not have to be added each time, but make it possible to generate previews.
Also, make use of AssistedInject to reduce the number of functions and LaunchedEffects needed.

Consequences

  • ConversationRouterHomeBridge is now replaced with simpler ConversationsScreenContent,
    which is a single composable to be used to create multiple screens that show conversation lists.
  • ConversationListViewModel uses AssistedInject to provide ConversationsSource and a Flow
    of search query Strings directly in constructor instead of doing it using multiple functions.
  • ConversationListViewModel and ConversationCallListViewModel are injected using unique keys,
    so that for each ConversationsSource there is a separate ViewModel. Thanks to that, together
    with assisted injection, they are now dedicated to each type which makes it easier to maintain,
    debug and even use on the same screen if needed.
  • Both mentioned ViewModels are now also interfaces that are implemented by the respective
    ConversationListViewModelImpl and ConversationCallListViewModelImpl and "preview" versions
    of these interfaces are also created to make it possible to generate composable previews.

@saleniuk
Copy link
Contributor Author

saleniuk commented Oct 1, 2024

Looks good to me! Before adding the ✅ What about adding ADR? since we are refactoring and removing lots of code (👏 ) and unifying to new ones (🙌 )

Good idea! I forgot about it, let me know if the ADR that I just added to this PR is fine or needs some improvements. 😄

@saleniuk saleniuk requested a review from yamilmedina October 1, 2024 14:11
Copy link

sonarqubecloud bot commented Oct 1, 2024

Copy link
Contributor

@yamilmedina yamilmedina left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Contributor

github-actions bot commented Oct 1, 2024

Built wire-android-staging-compat-pr-3480.apk is available for download

Copy link
Contributor

github-actions bot commented Oct 1, 2024

Built wire-android-dev-debug-pr-3480.apk is available for download

@saleniuk saleniuk added this pull request to the merge queue Oct 2, 2024
Merged via the queue into develop with commit c5e2908 Oct 2, 2024
13 checks passed
@saleniuk saleniuk deleted the refactor/unify-and-simplify-conversation-lists branch October 2, 2024 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes: technical-roadmap Work contributing to the Technical Roadmap, to improve our velocity or reduce the technical debt. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants