commit 46abcafa37ac0dc8f7669b4ccb3fe2b499fee1c0
parent 907abc2441805b391fe1badb6876a276109a9770
Author: Marcel <mtrnord1@gmail.com>
Date: Thu, 4 Jun 2020 21:25:00 +0200
Further optimizing by using optimized ruma-events crate
Took 53 minutes
Diffstat:
6 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
@@ -43,6 +43,7 @@ features = [
[patch.crates-io]
olm-sys = { git = "https://gitlab.gnome.org/stoically/olm-sys", branch = "wasm-target" }
cjson = { git = "https://github.com/engineerd/cjson" }
+ruma-events = { git = "https://github.com/ruma/ruma-events", branch = "struct-sizes" }
[profile.release]
# less code to include into binary
diff --git a/src/app.rs b/src/app.rs
@@ -16,6 +16,8 @@ pub enum AppRoute {
#[to = "/"]
MainView,
}
+
+#[allow(clippy::large_enum_variant)]
pub enum Msg {
RouteChanged(Route<()>),
ChangeRoute(AppRoute),
diff --git a/src/app/components/event_list.rs b/src/app/components/event_list.rs
@@ -25,8 +25,9 @@ pub struct State {
pub message: Option<String>,
}
+#[allow(clippy::large_enum_variant)]
pub enum Msg {
- NewMessage(Response),
+ NewMessage(Response),
SetMessage(String),
SendMessage,
Nope,
diff --git a/src/app/components/events/text.rs b/src/app/components/events/text.rs
@@ -64,7 +64,7 @@ impl Component for Text {
.text_event
.clone()
.unwrap()
- .formatted_body
+ .formatted
.is_some()
{
let message = if new_user {
@@ -75,17 +75,18 @@ impl Component for Text {
.text_event
.clone()
.unwrap()
- .formatted_body
- .as_ref()
+ .formatted
.unwrap()
+ .body
)
} else {
self.props
.text_event
.clone()
.unwrap()
- .formatted_body
+ .formatted
.unwrap()
+ .body
};
let js_text_event = {
let div = web_sys::window()
diff --git a/src/app/components/room_list.rs b/src/app/components/room_list.rs
@@ -18,6 +18,7 @@ pub struct RoomList {
props: Props,
}
+#[allow(clippy::large_enum_variant)]
pub enum Msg {
NewMessage(Response),
ChangeRoom(Room),
diff --git a/src/app/matrix.rs b/src/app/matrix.rs
@@ -3,7 +3,7 @@ use matrix_sdk::{
api::r0::{filter::RoomEventFilter, message::get_message_events::Direction},
events::{
collections::all::RoomEvent,
- room::message::{MessageEvent, MessageEventContent, TextMessageEventContent},
+ room::message::{MessageEvent, MessageEventContent, TextMessageEventContent, FormattedBody, MessageFormat},
EventJson,
},
identifiers::RoomId,
@@ -70,6 +70,7 @@ pub enum Request {
SendMessage((RoomId, String)),
}
+#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone)]
pub enum Response {
Error(MatrixError),
@@ -358,9 +359,11 @@ impl Agent for MatrixAgent {
} else {
MessageEventContent::Text(TextMessageEventContent {
body: message,
- format: Some("org.matrix.custom.html".to_string()),
- formatted_body: Some(formatted_message),
relates_to: None,
+ formatted: Some(FormattedBody{
+ body: formatted_message,
+ format: MessageFormat::Html,
+ })
})
};
client.room_send(&room_id, content, None).await;