Add support for updating media description and focus point when editing statuses (#3215)
* Add support for updating media description and focus point when editing statuses * Don't publish description/focus point updates via the standard api when editing a published post
This commit is contained in:
parent
d34586b7c8
commit
395e21c956
5 changed files with 43 additions and 17 deletions
|
|
@ -335,17 +335,20 @@ class ComposeViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
val updatedItem = newMediaList.find { it.localId == localId }
|
||||
if (updatedItem?.id != null) {
|
||||
val focus = updatedItem.focus
|
||||
val focusString = if (focus != null) "${focus.x},${focus.y}" else null
|
||||
return api.updateMedia(updatedItem.id, updatedItem.description, focusString)
|
||||
.fold({
|
||||
true
|
||||
}, { throwable ->
|
||||
Log.w(TAG, "failed to update media", throwable)
|
||||
false
|
||||
})
|
||||
if (!editing) {
|
||||
// Updates to media for already-published statuses need to go through the status edit api
|
||||
val updatedItem = newMediaList.find { it.localId == localId }
|
||||
if (updatedItem?.id != null) {
|
||||
val focus = updatedItem.focus
|
||||
val focusString = if (focus != null) "${focus.x},${focus.y}" else null
|
||||
return api.updateMedia(updatedItem.id, updatedItem.description, focusString)
|
||||
.fold({
|
||||
true
|
||||
}, { throwable ->
|
||||
Log.w(TAG, "failed to update media", throwable)
|
||||
false
|
||||
})
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,11 +48,12 @@ class MediaPreviewAdapter(
|
|||
val addFocusId = 2
|
||||
val editImageId = 3
|
||||
val removeId = 4
|
||||
if (item.state != ComposeActivity.QueuedMedia.State.PUBLISHED) {
|
||||
// Already-published items can't have their metadata edited
|
||||
popup.menu.add(0, addCaptionId, 0, R.string.action_set_caption)
|
||||
if (item.type == ComposeActivity.QueuedMedia.Type.IMAGE) {
|
||||
popup.menu.add(0, addFocusId, 0, R.string.action_set_focus)
|
||||
|
||||
popup.menu.add(0, addCaptionId, 0, R.string.action_set_caption)
|
||||
if (item.type == ComposeActivity.QueuedMedia.Type.IMAGE) {
|
||||
popup.menu.add(0, addFocusId, 0, R.string.action_set_focus)
|
||||
if (item.state != ComposeActivity.QueuedMedia.State.PUBLISHED) {
|
||||
// Already-published items can't be edited
|
||||
popup.menu.add(0, editImageId, 0, R.string.action_edit_image)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue