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:
parent
2a5e3cad29
commit
ee3f774ac5
2 changed files with 13 additions and 3 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
### New features 🚀
|
||||
|
||||
*
|
||||
* Download media (video and images) (#681)
|
||||
|
||||
### Design & UX 🔳
|
||||
|
||||
|
|
|
@ -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()
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue