mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 02:15:35 +03:00
Use new endpoint to delete voice broadcast with relations
This commit is contained in:
parent
0704fc5e15
commit
b0460ebcc0
3 changed files with 20 additions and 6 deletions
|
@ -20,6 +20,7 @@ import im.vector.app.features.voicebroadcast.VoiceBroadcastConstants
|
||||||
import im.vector.app.features.voicebroadcast.model.MessageVoiceBroadcastInfoContent
|
import im.vector.app.features.voicebroadcast.model.MessageVoiceBroadcastInfoContent
|
||||||
import im.vector.app.features.voicebroadcast.model.VoiceBroadcastState
|
import im.vector.app.features.voicebroadcast.model.VoiceBroadcastState
|
||||||
import im.vector.app.features.voicebroadcast.model.asVoiceBroadcastEvent
|
import im.vector.app.features.voicebroadcast.model.asVoiceBroadcastEvent
|
||||||
|
import im.vector.app.features.voicebroadcast.model.isVoiceBroadcast
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||||
|
@ -49,3 +50,7 @@ fun TimelineEvent.getVectorLastMessageContent(): MessageContent? {
|
||||||
else -> getLastMessageContent()
|
else -> getLastMessageContent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun TimelineEvent.isVoiceBroadcast(): Boolean {
|
||||||
|
return root.isVoiceBroadcast()
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import im.vector.app.R
|
||||||
import im.vector.app.SpaceStateHandler
|
import im.vector.app.SpaceStateHandler
|
||||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||||
|
import im.vector.app.core.extensions.isVoiceBroadcast
|
||||||
import im.vector.app.core.mvrx.runCatchingToAsync
|
import im.vector.app.core.mvrx.runCatchingToAsync
|
||||||
import im.vector.app.core.platform.VectorViewModel
|
import im.vector.app.core.platform.VectorViewModel
|
||||||
import im.vector.app.core.resources.BuildMeta
|
import im.vector.app.core.resources.BuildMeta
|
||||||
|
@ -859,12 +860,18 @@ class TimelineViewModel @AssistedInject constructor(
|
||||||
|
|
||||||
private fun handleRedactEvent(action: RoomDetailAction.RedactAction) {
|
private fun handleRedactEvent(action: RoomDetailAction.RedactAction) {
|
||||||
val event = room?.getTimelineEvent(action.targetEventId) ?: return
|
val event = room?.getTimelineEvent(action.targetEventId) ?: return
|
||||||
if (event.isLiveLocation()) {
|
when {
|
||||||
viewModelScope.launch {
|
event.isLiveLocation() -> {
|
||||||
redactLiveLocationShareEventUseCase.execute(event.root, room, action.reason)
|
viewModelScope.launch {
|
||||||
|
redactLiveLocationShareEventUseCase.execute(event.root, room, action.reason)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
event.isVoiceBroadcast() -> {
|
||||||
|
room.sendService().redactEvent(event.root, action.reason, listOf(RelationType.REFERENCE))
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
room.sendService().redactEvent(event.root, action.reason)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
room.sendService().redactEvent(event.root, action.reason)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,9 @@ value class VoiceBroadcastEvent(val root: Event) {
|
||||||
get() = root.content.toModel()
|
get() = root.content.toModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Event.isVoiceBroadcast() = type == VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map a [VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO] state event to a [VoiceBroadcastEvent].
|
* Map a [VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO] state event to a [VoiceBroadcastEvent].
|
||||||
*/
|
*/
|
||||||
fun Event.asVoiceBroadcastEvent() = if (type == VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO) VoiceBroadcastEvent(this) else null
|
fun Event.asVoiceBroadcastEvent() = if (isVoiceBroadcast()) VoiceBroadcastEvent(this) else null
|
||||||
|
|
Loading…
Reference in a new issue