Skip to content

Commit

Permalink
Expose conversation and last message on list (#1472)
Browse files Browse the repository at this point in the history
* remove the arc so it binds correctly

* Revert "remove the arc so it binds correctly"

This reverts commit e885828.

* add getters for the functions

* add the export

* remove the dead code
  • Loading branch information
nplasterer authored Jan 6, 2025
1 parent 91d5768 commit 7fe4b38
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,18 +1185,27 @@ impl TryFrom<UserPreferenceUpdate> for FfiPreferenceUpdate {
}
}

#[derive(uniffi::Object)]
#[derive(uniffi::Object, Clone)]
pub struct FfiConversation {
inner: MlsGroup<RustXmtpClient>,
}

#[derive(uniffi::Object)]
#[allow(unused_variables, dead_code)]
pub struct FfiConversationListItem {
conversation: FfiConversation,
last_message: Option<FfiMessage>,
}

#[uniffi::export]
impl FfiConversationListItem {
pub fn conversation(&self) -> Arc<FfiConversation> {
Arc::new(self.conversation.clone())
}
pub fn last_message(&self) -> Option<FfiMessage> {
self.last_message.clone()
}
}

impl From<MlsGroup<RustXmtpClient>> for FfiConversation {
fn from(mls_group: MlsGroup<RustXmtpClient>) -> FfiConversation {
FfiConversation { inner: mls_group }
Expand Down Expand Up @@ -1701,7 +1710,7 @@ impl FfiConversation {
}
}

#[derive(uniffi::Enum, PartialEq, Debug)]
#[derive(uniffi::Enum, PartialEq, Debug, Clone)]
pub enum FfiConversationMessageKind {
Application,
MembershipChange,
Expand Down Expand Up @@ -1760,7 +1769,7 @@ impl From<FfiDeliveryStatus> for DeliveryStatus {
}
}

#[derive(uniffi::Record)]
#[derive(uniffi::Record, Clone)]
pub struct FfiMessage {
pub id: Vec<u8>,
pub sent_at_ns: i64,
Expand Down

0 comments on commit 7fe4b38

Please sign in to comment.