fix(ui): fix early command check

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2021-09-29 17:06:11 +05:30
committed by xsahil03x
parent 35673f140c
commit 599c824fc0
@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:math'; import 'dart:math';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:collection/collection.dart';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
@@ -878,24 +879,11 @@ class MessageInputState extends State<MessageInput> {
void _checkCommands(String s, BuildContext context) { void _checkCommands(String s, BuildContext context) {
if (s.startsWith('/')) { if (s.startsWith('/')) {
final matchedCommandsList = StreamChannel.of(context) final allCommands = StreamChannel.of(context).channel.config?.commands;
.channel final command =
.config allCommands?.firstWhereOrNull((it) => it.name == s.substring(1));
?.commands if (command != null) {
.where((element) => element.name == s.substring(1)) return _setCommand(command);
.toList() ??
[];
if (matchedCommandsList.length == 1) {
_chosenCommand = matchedCommandsList[0];
textEditingController.clear();
if (_showCommandsOverlay) {
setState(() {
_commandEnabled = true;
_showCommandsOverlay = false;
});
}
} else if (!_showCommandsOverlay) { } else if (!_showCommandsOverlay) {
setState(() { setState(() {
_showCommandsOverlay = true; _showCommandsOverlay = true;