1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-10 10:00:44 +09:00

Enhancement/download media (#683)

This commit is contained in:
Evgenii Kozlov 2020-08-18 14:54:37 +02:00 committed by GitHub
parent 2a5e3cad29
commit ee3f774ac5
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -4,7 +4,7 @@
### New features 🚀
*
* Download media (video and images) (#681)
### Design & UX 🔳

View file

@ -1013,7 +1013,11 @@ class PageViewModel(
dispatch(Command.PopBackStack)
}
ActionItemType.Download -> {
_error.value = "Download not implemented"
viewModelScope.launch {
dispatch(Command.PopBackStack)
delay(300)
dispatch(Command.RequestDownloadPermission(id))
}
}
ActionItemType.Replace -> {
_error.value = "Replace not implemented"
@ -1841,13 +1845,19 @@ class PageViewModel(
}
fun startDownloadingFile(id: String) {
_error.value = "Downloading file in background..."
val block = blocks.first { it.id == id }
val file = block.content<Content.File>()
viewModelScope.launch {
orchestrator.proxies.intents.send(
Intent.Media.DownloadFile(
url = urlBuilder.file(file.hash),
url = when (file.type) {
Content.File.Type.IMAGE -> urlBuilder.image(file.hash)
else -> urlBuilder.file(file.hash)
},
name = file.name.orEmpty()
)
)