inline scss & collapable channels & show own messages
This commit is contained in:
+28
-2
@@ -549,9 +549,35 @@ fn accept_command(
|
||||
) -> Result<(), JsValue> {
|
||||
match command {
|
||||
Command::SendChat { markdown, channels } => {
|
||||
let html_text = markdown::to_html(&markdown);
|
||||
use markdown::*;
|
||||
let html_text = match tokenize(&markdown).as_slice() {
|
||||
block @ [Block::Paragraph(par)] => match par.as_slice() {
|
||||
[Span::Text(par)] => par.to_string(),
|
||||
_ => generate_markdown(block.to_vec())
|
||||
.trim()
|
||||
.strip_prefix("<p>")
|
||||
.unwrap()
|
||||
.strip_suffix("</p>")
|
||||
.unwrap()
|
||||
.to_string(),
|
||||
},
|
||||
block => generate_markdown(block.to_vec()).trim().to_string(),
|
||||
};
|
||||
|
||||
{
|
||||
let mut server = STATE.server.write();
|
||||
let Some(me) = server.session else {
|
||||
bail!("not signed in with a session id")
|
||||
};
|
||||
server.chat.push(Chat {
|
||||
raw: markdown,
|
||||
dangerous_html: html_text.clone(),
|
||||
sender: Some(me),
|
||||
})
|
||||
}
|
||||
|
||||
let mut u = msgs::TextMessage::new();
|
||||
u.set_message(html_text);
|
||||
u.set_message(html_text.to_string());
|
||||
u.set_channel_id(channels);
|
||||
let _ = send_chan.unbounded_send(u.into());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user