Skip to content

Commit

Permalink
Merge branch 'dev' into chat_friend_request
Browse files Browse the repository at this point in the history
  • Loading branch information
Flemmli97 authored Nov 9, 2023
2 parents ba419d3 + 6c23943 commit df06e93
Show file tree
Hide file tree
Showing 6 changed files with 1,224 additions and 1,198 deletions.
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
17 changes: 13 additions & 4 deletions kit/src/components/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,21 @@ fn markdown(text: &str, emojis: bool) -> String {
let txt = text.trim();

if emojis {
let r = replace_emojis(text);
if is_only_emojis(&r) {
let r = replace_emojis(txt);
// TODO: Watch this issue for a fix: https://github.com/open-i18n/rust-unic/issues/280
// This is a temporary workaround for some characters unic-emoji-char thinks are emojis
if !r.chars().all(char::is_alphanumeric) // for any numbers, eg 1, 11, 111
&& r != "#"
&& r != "*"
&& r != "##"
&& r != "**"
&& r != "-"
&& is_only_emojis(&r)
{
return format!("<span class=\"big-emoji\">{r}</span>");
} else if is_only_emojis(txt) || r == "-" {
return format!("<p>{txt}</p>");
}
} else if is_only_emojis(txt) {
return format!("<span class=\"big-emoji\">{txt}</span>");
}

let mut options = Options::empty();
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 @@ -454,11 +454,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
3 changes: 2 additions & 1 deletion ui/src/layouts/slimbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ pub fn SlimbarLayout(cx: Scope<Props>) -> Element {
id: "favorites",
aria_label: "Favorites",
favorites.iter().cloned().map(|chat| {
let users_typing = chat.typing_indicator.iter().any(|(k, _)| *k != state.read().did_key());
let users_typing = chat.typing_indicator.iter().any(|(k, _)| *k != state.read().did_key())
&& !state.read().chats_sidebar().contains(&chat);
let favorites_chat = chat.clone();
let remove_favorite = chat.clone();
let chat_id = chat.id;
Expand Down
Loading

0 comments on commit df06e93

Please sign in to comment.