Command parser is not a static object anymore

This commit is contained in:
Benoit Marty 2022-01-19 18:43:48 +01:00
parent 491044b0c5
commit eb4475b4d9
2 changed files with 4 additions and 2 deletions

View file

@ -23,8 +23,9 @@ import org.matrix.android.sdk.api.MatrixPatterns
import org.matrix.android.sdk.api.MatrixUrls.isMxcUrl
import org.matrix.android.sdk.api.session.identity.ThreePid
import timber.log.Timber
import javax.inject.Inject
object CommandParser {
class CommandParser @Inject constructor() {
/**
* Convert the text message into a Slash command.

View file

@ -66,6 +66,7 @@ class MessageComposerViewModel @AssistedInject constructor(
private val session: Session,
private val stringProvider: StringProvider,
private val vectorPreferences: VectorPreferences,
private val commandParser: CommandParser,
private val rainbowGenerator: RainbowGenerator,
private val voiceMessageHelper: VoiceMessageHelper,
private val voicePlayerHelper: VoicePlayerHelper
@ -183,7 +184,7 @@ class MessageComposerViewModel @AssistedInject constructor(
withState { state ->
when (state.sendMode) {
is SendMode.Regular -> {
when (val slashCommandResult = CommandParser.parseSlashCommand(action.text)) {
when (val slashCommandResult = commandParser.parseSlashCommand(action.text)) {
is ParsedCommand.ErrorNotACommand -> {
// Send the text message to the room
room.sendTextMessage(action.text, autoMarkdown = action.autoMarkdown)