refactor: use re-exported JsOption from ruma rather than directly adding it as a dependency

This commit is contained in:
Matthias Ahouansou 2024-02-25 10:30:30 +00:00
parent b27e9ea95c
commit 21a5fa3ef0
4 changed files with 6 additions and 13 deletions

1
Cargo.lock generated
View file

@ -387,7 +387,6 @@ dependencies = [
"http",
"hyper",
"image",
"js_option",
"jsonwebtoken",
"lazy_static",
"lru-cache",

View file

@ -116,9 +116,6 @@ async-trait = "0.1.68"
sd-notify = { version = "0.4.1", optional = true }
# stupid ruma using JsOption instead of Option
js_option = "0.1"
[target.'cfg(unix)'.dependencies]
nix = { version = "0.26.2", features = ["resource"] }

View file

@ -20,7 +20,7 @@ use ruma::{
StateEventType, TimelineEventType,
},
serde::Raw,
uint, DeviceId, OwnedDeviceId, OwnedUserId, RoomId, UInt, UserId,
uint, DeviceId, JsOption, OwnedDeviceId, OwnedUserId, RoomId, UInt, UserId,
};
use std::{
collections::{hash_map::Entry, BTreeMap, BTreeSet, HashMap, HashSet},
@ -1616,14 +1616,12 @@ pub async fn sync_events_v4_route(
sync_events::v4::SlidingSyncRoom {
name: services().rooms.state_accessor.get_name(room_id)?.or(name),
avatar: if let Some(avatar) = avatar {
ruma::JsOption::Some(avatar)
JsOption::Some(avatar)
} else {
match services().rooms.state_accessor.get_avatar(room_id)? {
ruma::JsOption::Some(avatar) => {
js_option::JsOption::from_option(avatar.url)
}
ruma::JsOption::Null => ruma::JsOption::Null,
ruma::JsOption::Undefined => ruma::JsOption::Undefined,
JsOption::Some(avatar) => JsOption::from_option(avatar.url),
JsOption::Null => JsOption::Null,
JsOption::Undefined => JsOption::Undefined,
}
},
initial: Some(roomsince == &0),

View file

@ -5,7 +5,6 @@ use std::{
};
pub use data::Data;
use js_option::JsOption;
use lru_cache::LruCache;
use ruma::{
events::{
@ -17,7 +16,7 @@ use ruma::{
},
StateEventType,
},
EventId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
EventId, JsOption, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
};
use tracing::error;