Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(quickprofile): Disable onblur for msg and hide profile on enter #1427

Merged
merged 11 commits into from
Nov 8, 2023
18 changes: 14 additions & 4 deletions common/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,11 +1194,21 @@ impl State {
msg: Vec<String>,
attachments: &[Location],
) -> Option<Uuid> {
let did = self.get_own_identity().did_key();
if let Some(id) = self.chats.active {
if let Some(chat) = self.chats.all.get_mut(&id) {
return Some(chat.append_pending_msg(id, did, msg, attachments));
}
return self.increment_outgoing_messages_for(msg, attachments, id);
}
None
}

pub fn increment_outgoing_messages_for(
&mut self,
msg: Vec<String>,
attachments: &[Location],
id: Uuid,
) -> Option<Uuid> {
let did = self.get_own_identity().did_key();
if let Some(chat) = self.chats.all.get_mut(&id) {
return Some(chat.append_pending_msg(id, did, msg, attachments));
}
None
}
Expand Down
7 changes: 5 additions & 2 deletions ui/src/layouts/chats/presentation/quick_profile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,14 @@ pub fn QuickProfileContext<'a>(cx: Scope<'a, QuickProfileProps<'a>>) -> Element<
hr{},
Input {
placeholder: get_local_text("quickprofile.chat-placeholder"),
disable_onblur: true,
onreturn: move |(val, _,_): (String,bool,Code)|{
let ui_id = state
let ui_id = chat_send.as_ref().and_then(|chat|state
.write_silent()
.increment_outgoing_messages(vec![val.clone()], &[]);
.increment_outgoing_messages_for(vec![val.clone()], &[], chat.id));
ch.send(QuickProfileCmd::Chat(chat_send.to_owned(), vec![val], ui_id));
let script = format!(r#"document.getElementById("{id}-context-menu").classList.add("hidden")"#);
let _ = eval(&script);
}
}
)
Expand Down
Loading