Merge pull request #1138 from vector-im/feature/join_command
Implementation of /join command (#12)
This commit is contained in:
commit
18d82b1bea
|
@ -5,7 +5,7 @@ Features ✨:
|
||||||
-
|
-
|
||||||
|
|
||||||
Improvements 🙌:
|
Improvements 🙌:
|
||||||
-
|
- Implementation of /join command
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
- Message transitions in encrypted rooms are jarring #518
|
- Message transitions in encrypted rooms are jarring #518
|
||||||
|
|
|
@ -292,16 +292,23 @@ class RoomDetailFragment @Inject constructor(
|
||||||
is RoomDetailViewEvents.Failure -> showErrorInSnackbar(it.throwable)
|
is RoomDetailViewEvents.Failure -> showErrorInSnackbar(it.throwable)
|
||||||
is RoomDetailViewEvents.OnNewTimelineEvents -> scrollOnNewMessageCallback.addNewTimelineEventIds(it.eventIds)
|
is RoomDetailViewEvents.OnNewTimelineEvents -> scrollOnNewMessageCallback.addNewTimelineEventIds(it.eventIds)
|
||||||
is RoomDetailViewEvents.ActionSuccess -> displayRoomDetailActionSuccess(it)
|
is RoomDetailViewEvents.ActionSuccess -> displayRoomDetailActionSuccess(it)
|
||||||
is RoomDetailViewEvents.ActionFailure -> displayRoomDetailActionFailure(it)
|
is RoomDetailViewEvents.ActionFailure -> displayRoomDetailActionFailure(it)
|
||||||
is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message, Snackbar.LENGTH_LONG)
|
is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message, Snackbar.LENGTH_LONG)
|
||||||
is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it)
|
is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it)
|
||||||
is RoomDetailViewEvents.FileTooBigError -> displayFileTooBigError(it)
|
is RoomDetailViewEvents.FileTooBigError -> displayFileTooBigError(it)
|
||||||
is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it)
|
is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it)
|
||||||
is RoomDetailViewEvents.SendMessageResult -> renderSendMessageResult(it)
|
is RoomDetailViewEvents.JoinRoomCommandSucces -> handleJoinedToAnotherRoom(it)
|
||||||
|
is RoomDetailViewEvents.SendMessageResult -> renderSendMessageResult(it)
|
||||||
}.exhaustive
|
}.exhaustive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleJoinedToAnotherRoom(action: RoomDetailViewEvents.JoinRoomCommandSucces) {
|
||||||
|
updateComposerText("")
|
||||||
|
lockSendButton = false
|
||||||
|
navigator.openRoom(vectorBaseActivity, action.roomId)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
|
|
|
@ -50,6 +50,7 @@ sealed class RoomDetailViewEvents : VectorViewEvents {
|
||||||
abstract class SendMessageResult : RoomDetailViewEvents()
|
abstract class SendMessageResult : RoomDetailViewEvents()
|
||||||
|
|
||||||
object MessageSent : SendMessageResult()
|
object MessageSent : SendMessageResult()
|
||||||
|
data class JoinRoomCommandSucces(val roomId: String) : SendMessageResult()
|
||||||
class SlashCommandError(val command: Command) : SendMessageResult()
|
class SlashCommandError(val command: Command) : SendMessageResult()
|
||||||
class SlashCommandUnknown(val command: String) : SendMessageResult()
|
class SlashCommandUnknown(val command: String) : SendMessageResult()
|
||||||
data class SlashCommandHandled(@StringRes val messageRes: Int? = null) : SendMessageResult()
|
data class SlashCommandHandled(@StringRes val messageRes: Int? = null) : SendMessageResult()
|
||||||
|
|
|
@ -379,8 +379,8 @@ class RoomDetailViewModel @AssistedInject constructor(
|
||||||
_viewEvents.post(RoomDetailViewEvents.SlashCommandNotImplemented)
|
_viewEvents.post(RoomDetailViewEvents.SlashCommandNotImplemented)
|
||||||
}
|
}
|
||||||
is ParsedCommand.JoinRoom -> {
|
is ParsedCommand.JoinRoom -> {
|
||||||
// TODO
|
handleJoinToAnotherRoomSlashCommand(slashCommandResult)
|
||||||
_viewEvents.post(RoomDetailViewEvents.SlashCommandNotImplemented)
|
popDraft()
|
||||||
}
|
}
|
||||||
is ParsedCommand.PartRoom -> {
|
is ParsedCommand.PartRoom -> {
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -512,6 +512,22 @@ class RoomDetailViewModel @AssistedInject constructor(
|
||||||
room.deleteDraft(NoOpMatrixCallback())
|
room.deleteDraft(NoOpMatrixCallback())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleJoinToAnotherRoomSlashCommand(command: ParsedCommand.JoinRoom) {
|
||||||
|
session.joinRoom(command.roomAlias, command.reason, object : MatrixCallback<Unit> {
|
||||||
|
override fun onSuccess(data: Unit) {
|
||||||
|
session.getRoomSummary(command.roomAlias)
|
||||||
|
?.roomId
|
||||||
|
?.let {
|
||||||
|
_viewEvents.post(RoomDetailViewEvents.JoinRoomCommandSucces(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(failure: Throwable) {
|
||||||
|
_viewEvents.post(RoomDetailViewEvents.SlashCommandResultError(failure))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
private fun legacyRiotQuoteText(quotedText: String?, myText: String): String {
|
private fun legacyRiotQuoteText(quotedText: String?, myText: String): String {
|
||||||
val messageParagraphs = quotedText?.split("\n\n".toRegex())?.dropLastWhile { it.isEmpty() }?.toTypedArray()
|
val messageParagraphs = quotedText?.split("\n\n".toRegex())?.dropLastWhile { it.isEmpty() }?.toTypedArray()
|
||||||
return buildString {
|
return buildString {
|
||||||
|
|
Loading…
Reference in New Issue