@@ -140,7 +140,7 @@ impl EventTimelineItem {
140140 }
141141
142142 /// Get the profile of the sender.
143- pub fn sender_profile ( & self ) -> & Profile {
143+ pub fn sender_profile ( & self ) -> & TimelineDetails < Profile > {
144144 match self {
145145 Self :: Local ( local_event) => & local_event. sender_profile ,
146146 Self :: Remote ( remote_event) => & remote_event. sender_profile ,
@@ -238,7 +238,7 @@ pub struct LocalEventTimelineItem {
238238 /// The sender of the event.
239239 pub sender : OwnedUserId ,
240240 /// The sender's profile of the event.
241- pub sender_profile : Profile ,
241+ pub sender_profile : TimelineDetails < Profile > ,
242242 /// The timestamp of the event.
243243 pub timestamp : MilliSecondsSinceUnixEpoch ,
244244 /// The content of the event.
@@ -275,7 +275,7 @@ pub struct RemoteEventTimelineItem {
275275 /// The sender of the event.
276276 pub sender : OwnedUserId ,
277277 /// The sender's profile of the event.
278- pub sender_profile : Profile ,
278+ pub sender_profile : TimelineDetails < Profile > ,
279279 /// The timestamp of the event.
280280 pub timestamp : MilliSecondsSinceUnixEpoch ,
281281 /// The content of the event.
@@ -375,6 +375,15 @@ pub enum TimelineDetails<T> {
375375 Error ( Arc < Error > ) ,
376376}
377377
378+ impl < T > TimelineDetails < T > {
379+ pub ( crate ) fn from_initial_value ( value : Option < T > ) -> Self {
380+ match value {
381+ Some ( v) => Self :: Ready ( v) ,
382+ None => Self :: Unavailable ,
383+ }
384+ }
385+ }
386+
378387/// The content of an [`EventTimelineItem`].
379388#[ derive( Clone , Debug ) ]
380389pub enum TimelineItemContent {
@@ -518,7 +527,7 @@ impl InReplyToDetails {
518527pub struct RepliedToEvent {
519528 pub ( super ) message : Message ,
520529 pub ( super ) sender : OwnedUserId ,
521- pub ( super ) sender_profile : Profile ,
530+ pub ( super ) sender_profile : TimelineDetails < Profile > ,
522531}
523532
524533impl RepliedToEvent {
@@ -533,7 +542,7 @@ impl RepliedToEvent {
533542 }
534543
535544 /// Get the profile of the sender.
536- pub fn sender_profile ( & self ) -> & Profile {
545+ pub fn sender_profile ( & self ) -> & TimelineDetails < Profile > {
537546 & self . sender_profile
538547 }
539548
@@ -558,7 +567,8 @@ impl RepliedToEvent {
558567 edited : event. relations ( ) . replace . is_some ( ) ,
559568 } ;
560569 let sender = event. sender ( ) . to_owned ( ) ;
561- let sender_profile = profile_provider. profile ( & sender) . await ;
570+ let sender_profile =
571+ TimelineDetails :: from_initial_value ( profile_provider. profile ( & sender) . await ) ;
562572
563573 Ok ( Self { message, sender, sender_profile } )
564574 }
0 commit comments