MESSENGER-5951 disable slash commands in old editor

This commit is contained in:
Frank Rotermund
2024-04-05 14:42:43 +02:00
parent 8c97d67697
commit c0df6eda87
@@ -163,26 +163,29 @@ class CompletionSuggestionService: CompletionSuggestionServiceProtocol {
})
}
case .slash:
commandProvider.fetchCommands { [weak self] commands in
guard let self else { return }
// bwi 5951 disable slash commands in old editor
if BWIBuildSettings.shared.enableWYSIWYGCommands {
commandProvider.fetchCommands { [weak self] commands in
guard let self else { return }
self.suggestionItems = commands.filtered(isRoomAdmin: self.commandProvider.isRoomAdmin).map { command in
CompletionSuggestionItem.command(value: CompletionSuggestionServiceCommandItem(
name: command.name,
parametersFormat: command.parametersFormat,
description: command.description
))
}
self.suggestionItems = commands.filtered(isRoomAdmin: self.commandProvider.isRoomAdmin).map { command in
CompletionSuggestionItem.command(value: CompletionSuggestionServiceCommandItem(
name: command.name,
parametersFormat: command.parametersFormat,
description: command.description
))
}
if textTrigger.text.isEmpty {
// A single `/` will display all available commands.
self.items.send(self.suggestionItems)
} else {
self.items.send(self.suggestionItems.filter { item in
guard case let .command(commandSuggestion) = item else { return false }
if textTrigger.text.isEmpty {
// A single `/` will display all available commands.
self.items.send(self.suggestionItems)
} else {
self.items.send(self.suggestionItems.filter { item in
guard case let .command(commandSuggestion) = item else { return false }
return commandSuggestion.name.lowercased().contains(textTrigger.text.lowercased())
})
return commandSuggestion.name.lowercased().contains(textTrigger.text.lowercased())
})
}
}
}
}