Skip to content

fix: Display button only when contact is not already saved#2966

Draft
Elouan1411 wants to merge 1 commit into
mainfrom
hide-add-contact-button
Draft

fix: Display button only when contact is not already saved#2966
Elouan1411 wants to merge 1 commit into
mainfrom
hide-add-contact-button

Conversation

@Elouan1411

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings June 30, 2026 08:57

Copilot AI left a comment

Copy link
Copy Markdown

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 aims to hide the “Add to contacts” action in the detailed contact bottom sheet when the recipient is already saved in the user’s remote address book. To support this, it introduces a parsed remote contact identifier from the contacts API and persists it in the user-info Realm.

Changes:

  • Add Contact.id parsing (int-or-string tolerant) and persist remoteContactId on MergedContact.
  • Hide the “Add to contacts” button based on merged-contact lookup from MainViewModel.
  • Bump USER_INFO_SCHEMA_VERSION to account for the updated user-info Realm schema.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
OldKotlin/realm-models/src/main/kotlin/com/infomaniak/mail/data/models/correspondent/MergedContact.kt Persist remoteContactId on MergedContact and populate it from API contacts.
OldKotlin/realm-models/src/main/kotlin/com/infomaniak/mail/data/models/correspondent/Contact.kt Add id field to the API Contact model using a custom serializer.
OldKotlin/realm-models/src/main/kotlin/com/infomaniak/mail/data/api/IntOrStringSerializer.kt Add a serializer to parse IDs returned as either JSON numbers or strings.
app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt Add shouldShowAddToContacts helper used by UI to decide button visibility.
app/src/main/java/com/infomaniak/mail/ui/main/thread/DetailedContactBottomSheetDialog.kt Toggle addToContacts visibility when opening the detailed contact bottom sheet.
app/src/main/java/com/infomaniak/mail/data/cache/RealmDatabase.kt Increment USER_INFO_SCHEMA_VERSION to reflect the new persisted field in user-info Realm.

Comment on lines +311 to +314
fun shouldShowAddToContacts(recipient: Recipient): Boolean {
val remoteContactId = mergedContactController.getMergedContactFromEmail(recipient.email)?.remoteContactId
return remoteContactId.isNullOrBlank()
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

iOS does not work that way

@Elouan1411 Elouan1411 force-pushed the hide-add-contact-button branch from 3273b21 to b3fbdb8 Compare June 30, 2026 09:04
@sonarqubecloud

Copy link
Copy Markdown

@FabianDevel FabianDevel marked this pull request as draft July 9, 2026 06:02
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.

2 participants