chore: Improve Chat Performance (#35)

* refactor

* optimistically update message list

* fix

* update

* handle duplicate messages

* update ui

* refactor input

* update multi line input

* clean up
This commit is contained in:
reya
2025-05-18 15:35:33 +07:00
committed by GitHub
parent 4f066b7c00
commit 443dbc82a6
37 changed files with 3060 additions and 1979 deletions

View File

@@ -10,7 +10,7 @@ use theme::ActiveTheme;
use crate::{
button::{Button, ButtonVariants},
input::TextInput,
input::InputState,
popover::{Popover, PopoverContent},
Icon,
};
@@ -24,12 +24,12 @@ impl_internal_actions!(emoji, [EmitEmoji]);
pub struct EmojiPicker {
icon: Option<Icon>,
anchor: Option<Corner>,
target_input: WeakEntity<TextInput>,
target_input: WeakEntity<InputState>,
emojis: Rc<Vec<SharedString>>,
}
impl EmojiPicker {
pub fn new(target_input: WeakEntity<TextInput>) -> Self {
pub fn new(target_input: WeakEntity<InputState>) -> Self {
let mut emojis: Vec<SharedString> = vec![];
emojis.extend(
@@ -102,7 +102,7 @@ impl RenderOnce for EmojiPicker {
move |_, window, cx| {
if let Some(input) = input.as_ref() {
input.update(cx, |this, cx| {
let current = this.text();
let current = this.value();
let new_text = if current.is_empty() {
format!("{}", item)
} else if current.ends_with(" ") {
@@ -110,7 +110,7 @@ impl RenderOnce for EmojiPicker {
} else {
format!("{} {}", current, item)
};
this.set_text(new_text, window, cx);
this.set_value(new_text, window, cx);
});
}
}