mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-24 18:36:21 +03:00
Improve code
This commit is contained in:
parent
9802ed08e3
commit
5076369173
4 changed files with 16 additions and 9 deletions
|
@ -49,7 +49,7 @@ enum class Command(val command: String, val parameters: String, @StringRes val d
|
|||
SPOILER("/spoiler", "<message>", R.string.command_description_spoiler, false),
|
||||
POLL("/poll", "Question | Option 1 | Option 2 ...", R.string.command_description_poll, false),
|
||||
SHRUG("/shrug", "<message>", R.string.command_description_shrug, false),
|
||||
LENNY("/lenny", "[<message>]", R.string.command_description_lenny, false),
|
||||
LENNY("/lenny", "<message>", R.string.command_description_lenny, false),
|
||||
PLAIN("/plain", "<message>", R.string.command_description_plain, false),
|
||||
WHOIS("/whois", "<user-id>", R.string.command_description_whois, false),
|
||||
DISCARD_SESSION("/discardsession", "", R.string.command_description_discard_session, false),
|
||||
|
|
|
@ -48,7 +48,6 @@ import im.vector.app.features.createdirect.DirectRoomHelper
|
|||
import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy
|
||||
import im.vector.app.features.crypto.verification.SupportedVerificationMethodsProvider
|
||||
import im.vector.app.features.home.room.detail.composer.VoiceMessageHelper
|
||||
import im.vector.app.features.home.room.detail.composer.rainbow.RainbowGenerator
|
||||
import im.vector.app.features.home.room.detail.sticker.StickerPickerActionHandler
|
||||
import im.vector.app.features.home.room.detail.timeline.factory.TimelineFactory
|
||||
import im.vector.app.features.home.room.detail.timeline.url.PreviewUrlRetriever
|
||||
|
|
|
@ -19,7 +19,6 @@ package im.vector.app.features.home.room.detail.composer
|
|||
import androidx.annotation.StringRes
|
||||
import im.vector.app.core.platform.VectorViewEvents
|
||||
import im.vector.app.features.command.Command
|
||||
import im.vector.app.features.home.room.detail.RoomDetailViewEvents
|
||||
|
||||
sealed class TextComposerViewEvents : VectorViewEvents {
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ import org.matrix.android.sdk.api.session.Session
|
|||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||
import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomAvatarContent
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
|
||||
|
@ -607,15 +606,20 @@ class TextComposerViewModel @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun getLastMemberEvent(): RoomMemberContent {
|
||||
private fun getMyRoomMemberContent(): RoomMemberContent? {
|
||||
return room.getStateEvent(EventType.STATE_ROOM_MEMBER, QueryStringValue.Equals(session.myUserId))
|
||||
?.content?.toModel<RoomMemberContent>()
|
||||
?: RoomMemberContent(membership = Membership.JOIN)
|
||||
?.content
|
||||
?.toModel<RoomMemberContent>()
|
||||
}
|
||||
|
||||
private fun handleChangeDisplayNameForRoomSlashCommand(changeDisplayName: ParsedCommand.ChangeDisplayNameForRoom) {
|
||||
launchSlashCommandFlowSuspendable {
|
||||
room.sendStateEvent(EventType.STATE_ROOM_MEMBER, session.myUserId, getLastMemberEvent().copy(displayName = changeDisplayName.displayName).toContent())
|
||||
getMyRoomMemberContent()
|
||||
?.copy(displayName = changeDisplayName.displayName)
|
||||
?.toContent()
|
||||
?.let {
|
||||
room.sendStateEvent(EventType.STATE_ROOM_MEMBER, session.myUserId, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -627,7 +631,12 @@ class TextComposerViewModel @AssistedInject constructor(
|
|||
|
||||
private fun handleChangeAvatarForRoomSlashCommand(changeAvatar: ParsedCommand.ChangeAvatarForRoom) {
|
||||
launchSlashCommandFlowSuspendable {
|
||||
room.sendStateEvent(EventType.STATE_ROOM_MEMBER, session.myUserId, getLastMemberEvent().copy(avatarUrl = changeAvatar.url).toContent())
|
||||
getMyRoomMemberContent()
|
||||
?.copy(avatarUrl = changeAvatar.url)
|
||||
?.toContent()
|
||||
?.let {
|
||||
room.sendStateEvent(EventType.STATE_ROOM_MEMBER, session.myUserId, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue