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

MessagesAction Update to also handle non-actionable messages without failing #168

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pauljohanneskraft
Copy link
Contributor

MessagesAction Update to also handle non-actionable messages without failing

♻️ Current situation & Problem

Previously, the app would handle a non-existing action as a failure, whereas it can simply be ignored and a message should then either be dismissible or will be dismissed automatically based on other user input.

⚙️ Release Notes

Add a bullet point list summary of the feature and possible migration guides if this is a breaking change so this section can be added to the release notes.
Include code snippets that provide examples of the feature implemented or links to the documentation if it appends or changes the public interface.

📚 Documentation

Please ensure that you properly document any additions in conformance to Spezi Documentation Guide.
You can use this section to describe your solution, but we encourage contributors to document your reasoning and changes using in-line documentation.

✅ Testing

Please ensure that the PR meets the testing requirements set by CodeCov and that new functionality is appropriately tested.
This section describes important information about the tests and why some elements might not be testable.

📝 Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

@pauljohanneskraft pauljohanneskraft self-assigned this Jan 14, 2025
@pauljohanneskraft pauljohanneskraft added the enhancement New feature or request label Jan 14, 2025
@pauljohanneskraft pauljohanneskraft linked an issue Jan 14, 2025 that may be closed by this pull request
1 task
@pauljohanneskraft
Copy link
Contributor Author

pauljohanneskraft commented Jan 14, 2025

I would like to discuss this further before merging, since there seem to be quite a few UI differences between messages on iOS and Android and I would rather discuss them before throwing out existing functionality here.

Examples:

  • iOS has multi-line collapsing only after 3+ lines (by using a text button "Read more") and I'm not sure whether it is really intuitive there considering that if you tap on the collapsible message, the action is performed, so it is actually really hard to collapse and not perform the action instead. Android has that right chevron icon instead - We may want to think to just never collapse, right?

  • iOS differentiates between dismissing and performing an action. Where you may dismiss a message on iOS without performing its action, you can only interact with a message using the "Finish" button on Android. Further, the "Finish" text is bound to the action type, which is not the case for Android.

  • Due date is not displayed on iOS and may be removed on Android, since we do not set it on the server anymore (and if we do in some rare occasions, we do not need to visualize it).

  • The isLoading property on Message shouldn't be in the model type but is rather UI-exclusive. Therefore, we could, for example, write a small wrapper type or something to add those UI-exclusive values.

@@ -14,7 +14,7 @@ class MessageActionMapper @Inject constructor() {
fun map(action: String?): Result<MessagesAction> {
return runCatching {
Copy link
Contributor

Choose a reason for hiding this comment

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

there is another error being thrown in the else case. I would propose changing the return type of this method to MessageAction? instead of result and update to runCatching { // exisiting logic }.getOrNull(). No need for NoAction imo as we can represent it with the null case

@@ -15,7 +15,6 @@ data class Message(
val description: String? = null,
val action: String?,
val isDismissible: Boolean = true,
val isLoading: Boolean = false,
Copy link
Contributor

Choose a reason for hiding this comment

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

There is some logic in HomeViewModel that shows a loading indicator while a message is being processed, e.g. health summary pdf generation. I think we still need this

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 found this out now, yes - but I believe this should actually be in some wrapper type or something, since it has nothing to do with the model itself. Like this, I would assume that the server sends us this information, which is not the case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Totally agree, in general there should be distinct types for domain and ui layer, e.g. Message and MessageUiModel and currently the message is serving for both layers

@@ -30,6 +30,7 @@ class MessagesHandler @Inject constructor(
val actionResult = messagesActionMapper.map(action = message.action)
var failure = actionResult.exceptionOrNull()
when (val messagesAction = actionResult.getOrNull()) {
is MessagesAction.NoAction -> Unit
Copy link
Contributor

Choose a reason for hiding this comment

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

it should not be needed as it is covered in the else case (applies also in case you change the response to nullable instead of result)

Question: Should we complete the message below if we could not map any action for it?

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'm not sure actually, would need to check iOS

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 checked: iOS only calls dismissMessage, if an action has been performed and the message has isDismissible set to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

Clicking Finish on app notifications brings about error message
2 participants