element-hq / element-hq/element-android

Move "saveMedia" code into "DownloadMediaUseCase"

Open
#5,374 0 comments 0 reactions 0 assignees View on GitHub
T-Enhancement T-Task
Dominant language
Kotlin
Stars
3.7k
Forks
917
PR merge metrics
No merged PRs in 30d

Description

### Your use case

#### What would you like to do?

As suggested in [this comment](https://github.com/vector-im/element-android/pull/5349#discussion_r815724775), we may move the existing code of the [static method saveMedia](https://github.com/vector-im/element-android/blob/41628ea5115b73568d002e07ffaab01bc20685ef/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt#L251) into the existing `DownloadMediaUseCase` introduced in [this PR](https://github.com/vector-im/element-android/pull/5349).

We should update corresponding unit tests as well.
We should replace usage of `saveMedia` by the `UseCase`.

#### Why would you like to do it?

Generally static methods are hard to unit tests. In order to ease unit tests and reusability, we may use UseCase pattern instead.

#### How would you like to achieve it?

- Move existing `saveMedia` code inside `DownloadMediaUseCase`
- Update unit tests of the use case
- Replace all usages of `saveMedia` by the `UseCase` (ideally the call site should be into a ViewModel)

### Have you considered any alternatives?

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.