mirror of
https://github.com/tommyxchow/frosty.git
synced 2025-08-06 17:48:14 +08:00
Fix chat autocomplete not updating (#267)
This commit is contained in:
@ -127,6 +127,9 @@ abstract class ChatStoreBase with Store {
|
||||
@readonly
|
||||
var _autoScroll = true;
|
||||
|
||||
@readonly
|
||||
var _inputText = '';
|
||||
|
||||
@readonly
|
||||
var _showSendButton = false;
|
||||
|
||||
@ -204,12 +207,13 @@ abstract class ChatStoreBase with Store {
|
||||
|
||||
// Add a listener to the textfield that will show/hide the autocomplete bar if focused.
|
||||
// Will also rebuild the autocomplete bar when typing, refreshing the results as the user types.
|
||||
textController.addListener(() => _showEmoteAutocomplete =
|
||||
!_showMentionAutocomplete &&
|
||||
textFieldFocusNode.hasFocus &&
|
||||
textController.text.split(' ').last.isNotEmpty);
|
||||
|
||||
textController.addListener(() {
|
||||
_inputText = textController.text;
|
||||
|
||||
_showEmoteAutocomplete = !_showMentionAutocomplete &&
|
||||
textFieldFocusNode.hasFocus &&
|
||||
textController.text.split(' ').last.isNotEmpty;
|
||||
|
||||
_showSendButton = textController.text.isNotEmpty;
|
||||
_showMentionAutocomplete = textFieldFocusNode.hasFocus &&
|
||||
textController.text.split(' ').last.startsWith('@');
|
||||
|
@ -119,6 +119,24 @@ mixin _$ChatStore on ChatStoreBase, Store {
|
||||
});
|
||||
}
|
||||
|
||||
late final _$_inputTextAtom =
|
||||
Atom(name: 'ChatStoreBase._inputText', context: context);
|
||||
|
||||
String get inputText {
|
||||
_$_inputTextAtom.reportRead();
|
||||
return super._inputText;
|
||||
}
|
||||
|
||||
@override
|
||||
String get _inputText => inputText;
|
||||
|
||||
@override
|
||||
set _inputText(String value) {
|
||||
_$_inputTextAtom.reportWrite(value, super._inputText, () {
|
||||
super._inputText = value;
|
||||
});
|
||||
}
|
||||
|
||||
late final _$_showSendButtonAtom =
|
||||
Atom(name: 'ChatStoreBase._showSendButton', context: context);
|
||||
|
||||
|
@ -39,16 +39,23 @@ class ChatBottomBar extends StatelessWidget {
|
||||
...chatStore.assetsStore.ffzEmotes,
|
||||
...chatStore.assetsStore.sevenTVEmotes
|
||||
]
|
||||
.where((emote) => emote.name.toLowerCase().contains(
|
||||
chatStore.textController.text.split(' ').last.toLowerCase()))
|
||||
.where(
|
||||
(emote) => emote.name.toLowerCase().contains(
|
||||
chatStore.inputText.split(' ').last.toLowerCase(),
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
||||
final matchingChatters = chatStore.chatDetailsStore.chatUsers
|
||||
.where((chatter) => chatter.contains(chatStore.textController.text
|
||||
.split(' ')
|
||||
.last
|
||||
.replaceFirst('@', '')
|
||||
.toLowerCase()))
|
||||
.where(
|
||||
(chatter) => chatter.contains(
|
||||
chatStore.inputText
|
||||
.split(' ')
|
||||
.last
|
||||
.replaceFirst('@', '')
|
||||
.toLowerCase(),
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
||||
return Column(
|
||||
|
Reference in New Issue
Block a user