Browse Source

chore: Upgrade matrix-sdk

fractal-9
Kévin Commaille 1 year ago
parent
commit
8e38f554e3
No known key found for this signature in database
GPG Key ID: C971D9DBC9D678D
  1. 394
      Cargo.lock
  2. 4
      Cargo.toml
  3. 14
      src/components/avatar/image.rs
  4. 59
      src/session/model/room/mod.rs

394
Cargo.lock generated

File diff suppressed because it is too large Load Diff

4
Cargo.toml

@ -67,7 +67,7 @@ sourceview = { package = "sourceview5", version = "0.9" }
[dependencies.matrix-sdk]
git = "https://github.com/matrix-org/matrix-rust-sdk.git"
rev = "5ba90611b43915926a37be83f3de1d4d53bca6bd"
rev = "65b422312c27a1b7f5a8e25f1156d1a1d6691cc1"
features = [
"socks",
"sso-login",
@ -77,7 +77,7 @@ features = [
[dependencies.matrix-sdk-ui]
git = "https://github.com/matrix-org/matrix-rust-sdk.git"
rev = "5ba90611b43915926a37be83f3de1d4d53bca6bd"
rev = "65b422312c27a1b7f5a8e25f1156d1a1d6691cc1"
[dependencies.ruma]
# version = "0.10"

14
src/components/avatar/image.rs

@ -51,7 +51,7 @@ mod imp {
#[property(get = Self::uri_string)]
uri_string: PhantomData<Option<String>>,
/// Information about the avatar.
pub(super) info: RefCell<Option<Box<ImageInfo>>>,
pub(super) info: RefCell<Option<ImageInfo>>,
/// The source of the avatar's URI.
#[property(get, construct_only, builder(AvatarUriSource::default()))]
pub uri_source: Cell<AvatarUriSource>,
@ -112,12 +112,12 @@ mod imp {
}
/// Information about the avatar.
pub(super) fn info(&self) -> Option<Box<ImageInfo>> {
pub(super) fn info(&self) -> Option<ImageInfo> {
self.info.borrow().clone()
}
/// Set information about the avatar.
pub(super) fn set_info(&self, info: Option<Box<ImageInfo>>) {
pub(super) fn set_info(&self, info: Option<ImageInfo>) {
self.info.replace(info);
}
@ -161,7 +161,7 @@ impl AvatarImage {
session: &Session,
uri_source: AvatarUriSource,
uri: Option<OwnedMxcUri>,
info: Option<Box<ImageInfo>>,
info: Option<ImageInfo>,
) -> Self {
let obj = glib::Object::builder::<Self>()
.property("session", session)
@ -173,7 +173,7 @@ impl AvatarImage {
}
/// Set the Matrix URI and information of the avatar.
pub fn set_uri_and_info(&self, uri: Option<OwnedMxcUri>, info: Option<Box<ImageInfo>>) {
pub fn set_uri_and_info(&self, uri: Option<OwnedMxcUri>, info: Option<ImageInfo>) {
let imp = self.imp();
let changed = imp.set_uri(uri);
@ -190,7 +190,7 @@ impl AvatarImage {
}
/// Information about the avatar.
pub fn info(&self) -> Option<Box<ImageInfo>> {
pub fn info(&self) -> Option<ImageInfo> {
self.imp().info()
}
@ -234,7 +234,7 @@ impl AvatarImage {
let downloader = ThumbnailDownloader {
main: ImageSource {
source: (&uri).into(),
info: info.as_deref().map(Into::into),
info: info.as_ref().map(Into::into),
},
// Avatars are not encrypted so we should always get the thumbnail from the original.
alt: None,

59
src/session/model/room/mod.rs

@ -9,11 +9,9 @@ use gtk::{
subclass::prelude::*,
};
use matrix_sdk::{
deserialized_responses::{AmbiguityChange, SyncOrStrippedState},
event_handler::EventHandlerDropGuard,
room::Room as MatrixRoom,
send_queue::RoomSendQueueUpdate,
DisplayName, Result as MatrixResult, RoomInfo, RoomMemberships, RoomState,
deserialized_responses::AmbiguityChange, event_handler::EventHandlerDropGuard,
room::Room as MatrixRoom, send_queue::RoomSendQueueUpdate, DisplayName, Result as MatrixResult,
RoomInfo, RoomMemberships, RoomState,
};
use ruma::{
api::client::{
@ -23,10 +21,9 @@ use ruma::{
events::{
receipt::ReceiptThread,
room::{
avatar::RoomAvatarEventContent, guest_access::GuestAccess,
history_visibility::HistoryVisibility, member::SyncRoomMemberEvent,
guest_access::GuestAccess, history_visibility::HistoryVisibility,
member::SyncRoomMemberEvent,
},
SyncStateEvent,
},
EventId, MatrixToUri, MatrixUri, OwnedEventId, OwnedRoomId, OwnedUserId, RoomId, UserId,
};
@ -433,7 +430,7 @@ mod imp {
}
/// Update the avatar of the room.
async fn update_avatar(&self) {
fn update_avatar(&self) {
let Some(session) = self.session.upgrade() else {
return;
};
@ -451,34 +448,8 @@ mod imp {
}
if let Some(avatar_url) = room_avatar_url {
// The avatar has changed, try to load its info.
let matrix_room = matrix_room.clone();
let handle = spawn_tokio!(async move {
matrix_room
.get_state_event_static::<RoomAvatarEventContent>()
.await
});
let avatar_event = match handle.await.expect("task was not aborted") {
Ok(Some(raw_event)) => match raw_event.deserialize() {
Ok(event) => Some(event),
Err(error) => {
warn!("Could not deserialize room avatar event: {error}");
None
}
},
Ok(None) => None,
Err(error) => {
warn!("Could not get room avatar event: {error}");
None
}
};
let avatar_info = match avatar_event {
Some(SyncOrStrippedState::Sync(SyncStateEvent::Original(e))) => e.content.info,
Some(SyncOrStrippedState::Stripped(e)) => e.content.info,
_ => None,
};
// The avatar has changed, update it.
let avatar_info = matrix_room.avatar_info();
if let Some(avatar_image) = avatar_data
.image()
@ -912,17 +883,7 @@ mod imp {
self.direct_member.replace(member);
self.obj().notify_direct_member();
spawn!(
glib::Priority::DEFAULT_IDLE,
clone!(
#[weak(rename_to = imp)]
self,
async move {
imp.update_avatar().await;
}
)
);
self.update_avatar();
}
/// The ID of the other user, if this is a direct chat and there is only
@ -1355,7 +1316,7 @@ mod imp {
self.aliases.update();
self.update_name();
self.update_display_name().await;
self.update_avatar().await;
self.update_avatar();
self.update_topic();
self.update_category();
self.update_tombstone();

Loading…
Cancel
Save