fix: Display button only when contact is not already saved - #2966
fix: Display button only when contact is not already saved#2966Elouan1411 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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.idparsing (int-or-string tolerant) and persistremoteContactIdonMergedContact. - Hide the “Add to contacts” button based on merged-contact lookup from
MainViewModel. - Bump
USER_INFO_SCHEMA_VERSIONto 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. |
| fun shouldShowAddToContacts(recipient: Recipient): Boolean { | ||
| val remoteContactId = mergedContactController.getMergedContactFromEmail(recipient.email)?.remoteContactId | ||
| return remoteContactId.isNullOrBlank() | ||
| } |
There was a problem hiding this comment.
iOS does not work that way
3273b21 to
b3fbdb8
Compare
|
|
We are waiting for a backend update to get a route for deleting a contact. Therefore, the button will function to add if the person is not in the contacts, and to delete otherwise. |



No description provided.