Commit Graph

18 Commits

Author SHA1 Message Date
Zorica Stojchevska 30e5087084 Update copyright
MAILAND-2696
2022-05-23 21:01:57 +00:00
Davide Farella 33e640c208 Replace `setImagesAndStartProcess` and `result` in MessageRenderer.kt
Usage replaced by MessageRenderer.setImagesAndProcess

MAILAND-2332
2021-10-18 15:08:46 +00:00
Davide Farella b23e133fbd Introduce MessageRenderer.setImagesAndProcess
This is a suspend function that returns the `RenderedMessage`, instead of `setImagesAndStartProcess`, which is a fire-and-forget, with the result returned on a separate stream.

This will allow us to have more consistency in the class.

MAILAND-2332
2021-10-18 15:08:46 +00:00
Davide Farella f3b0fbd8d3 Add support for multi message in MessageRenderer
MAILAND-2332
2021-10-18 15:08:46 +00:00
Davide Farella eb26e1db37 Create models for MessageRenderer.kt
Models are needed for the purpose of keeping a track of the message's id and body, removing a dependencies of the class' variable and so preparing it for support multiple messages

MAILAND-2332
2021-10-18 15:08:46 +00:00
Davide Farella 34d3058406 Replace usages of MessageRenderer.kt with new API
MAILAND-2332
2021-10-18 15:08:46 +00:00
Davide Farella bb1d8e665f Redesign API surface for MessageRenderer.kt
The class was exposing fields and Channel's, but this is breaking the principle of Encapsulation. These members are now deprecated, in favour of more standards functions and Flow as result.

The inputs now also require a message's id, in preparation of the support for multiple messages rendering

MAILAND-2332
2021-10-18 15:08:46 +00:00
Davide Farella 165b1b2eb3 Revert changes from '3cf1ac16' in MessageRenderer.kt
The class is not designed for render different messages, changing the `messagesBody` is incorrect, as that can happen in any moment, while the process is already started, resulting in many errors, for example displaying twice the same message or being unable to load images.

Usage in conversations must be implemented in a different way
2021-10-18 15:08:46 +00:00
Marino Meneghel 3cf1ac163d Display embedded images for each message in a conversation
after they were loaded through the "Display embedded images" button for
any message.

There were some issues preventing the functionality from working which
were addressed in this PR:
- The same instance of MessageRenderer was not ready to work with
different messages (messageBody was not changeable and the is a check
that would stop execution when an image was "already rendered" which
didn't take account that different messages can contain the same image)
- When MessageRenderer returns the html, we need to display that
  through a new livedata which targets only the message currently opened,
  as resetting the whole ConversationUiModel causes UI glitches when the
  message is not the last one.

MAILAND-1931
2021-06-30 15:47:31 +00:00
Marino Meneghel 7112a96760 Prevent crash when embedded image local file name is null
In some cases the message rendering gets triggered again with invalid
(null) values in place of the prevously-valid ones for embedded images
local files. We will skip such invalid values

MAILAND-1770
2021-06-14 17:34:51 +02:00
Marino Meneghel b249049468 Change MessageRenderer to define images directory dynamically
Since the "file directory" where images are stored is the messageId,
injecting it at class creation is not sufficient anymore with the
addition of conversations (when showing a converation's details
MessageRenderer would be init with conversationId, which is not a valid
image directory and would cause images not to be found).

The directory is now defined using each embedded image `messageId` field

MAILAND-1770
2021-06-14 17:34:51 +02:00
Marino Meneghel 99b0d41d77 Adapt 'load embedded images' functionality to work for conversations too
Beforehand, this functionality was working by injecting a string (the
html body with the images) into the adapter which would replace any
content of the webview with the new string. As with conversations we can
have multiple webviews, this didn't work anymore.

The new approach leverages the components currently in place to avoid
touching on a too wide scope: `MessageRenderer` is still in charge of
creating a message body with inline images. Such body is now being
returned with the messageId to which the body refers too. It's observed
in the MessageDetailsViewModel.init method and when fired it "hot swaps"
the `decryptedHtml` on the correct message and emit the
convresationUiModel again for the adapter to refresh the displayed data.

Summary of tech changes:
- Changed MessageRender to return an object containing both the
"rendered message body" and the messageId for which such body was rendered
- Removed `distinctUntilChanged` from _decryptedMessageLiveData as it
prevented embedded images from being emitted (as Message.decryptedHtml
field is not considered for computing equality)

- Rename `embeddedImagesAttachments` field following naming conventions
- `prepareEmbeddedImages` method receives message for which images should be prepared
- Message.decryptedHTML field can be set from outside of the model
- Remove redundant downloadEmbeddedImagesResult live data

MAILAND-1770
2021-06-14 17:34:51 +02:00
Marino Meneghel d726b2859d Move debounceDelayMillis to a constant class field 2021-05-10 13:38:10 +00:00
Marino Meneghel e4dddd2ce0 Fix failing unit tests due to use of experimental API
Both ComposeMessageViewModelTest and MessageRendererTest were failing
because of issues related to usage of experimental delay method

MAILAND-1647
2021-05-10 13:38:10 +00:00
Tomasz Giszczak 6df695a9a9 Extracted EmbedeedImage mapper to AttachmentsHelper.
MAILAND-1337
2021-02-09 16:42:51 +01:00
Davide Farella 5c3f788eaa Fix MessageRendererTest.kt
Tests were failing because coroutines-test was not used and objects were not properly mocked.
Additionally another test has been added
Affected: MessageRendererTest.kt
2020-09-25 07:04:52 +00:00
Davide Farella 04cf9199e3 Setup all the classes for enabled automatic Injection generation
* Replaced member injection with constructor injection
* Setup aimed to let Dagger/Hilt generate dependency graph automatically, where possible
Affected: Dagger dependencies

MAILAND-930
2020-09-22 13:56:55 +02:00
Zorica Stojchevska 5ce164d00a Initial commit 2020-04-16 17:44:53 +02:00