fix boosting and voting in boosted statuses (this time for real)

This commit is contained in:
Konrad Pozniak 2021-07-01 20:54:02 +02:00
parent 15c43f9971
commit 4ff0989835
1 changed files with 6 additions and 15 deletions

View File

@ -369,7 +369,7 @@ class TimelineViewModel @Inject constructor(
fun voteInPoll(position: Int, choices: List<Int>): Job = viewModelScope.launch {
val status = statuses[position].asStatusOrNull() ?: return@launch
val poll = status.status.poll ?: run {
val poll = status.actionable.poll ?: run {
Log.w(TAG, "No poll on status ${status.id}")
return@launch
}
@ -390,8 +390,8 @@ class TimelineViewModel @Inject constructor(
status: StatusViewData.Concrete,
newPoll: Poll
) {
updateStatusById(status.id) {
it.copy(status = it.status.copy(poll = newPoll))
updateActionableStatusById(status.id) {
it.copy(poll = newPoll)
}
}
@ -712,8 +712,8 @@ class TimelineViewModel @Inject constructor(
}
private fun handleReblogEvent(reblogEvent: ReblogEvent) {
updateStatusById(reblogEvent.statusId) {
it.copy(status = it.status.copy(reblogged = reblogEvent.reblog))
updateActionableStatusById(reblogEvent.statusId) {
it.copy(reblogged = reblogEvent.reblog)
}
}
@ -862,7 +862,7 @@ class TimelineViewModel @Inject constructor(
id: String,
updater: (Status) -> Status
) {
val pos = statuses.indexOfFirst { it.asStatusOrNull()?.id == id }
val pos = statuses.indexOfFirst { it.asStatusOrNull()?.actionableId == id }
if (pos == -1) return
updateStatusAt(pos) {
if (it.status.reblog != null) {
@ -873,15 +873,6 @@ class TimelineViewModel @Inject constructor(
}
}
private inline fun updateStatusById(
id: String,
updater: (StatusViewData.Concrete) -> StatusViewData.Concrete
) {
val pos = statuses.indexOfFirst { it.asStatusOrNull()?.id == id }
if (pos == -1) return
updateStatusAt(pos, updater)
}
private inline fun updateStatusAt(
position: Int,
updater: (StatusViewData.Concrete) -> StatusViewData.Concrete