1
- use std:: ops:: DerefMut ;
1
+ use std:: { collections :: BTreeMap , ops:: DerefMut } ;
2
2
3
3
use indexmap:: IndexMap ;
4
4
use makepad_widgets:: * ;
5
- use matrix_sdk_ui:: timeline:: { AnyOtherFullStateEventContent , InReplyToDetails , ReactionsByKeyBySender , TimelineDetails , TimelineEventItemId } ;
5
+ use matrix_sdk_ui:: timeline:: { AnyOtherFullStateEventContent , InReplyToDetails , Profile , ReactionsByKeyBySender , TimelineDetails , TimelineEventItemId } ;
6
6
use ruma:: { events:: { receipt:: Receipt , room:: message:: { AudioMessageEventContent , EmoteMessageEventContent , FileMessageEventContent , FormattedBody , ImageMessageEventContent , KeyVerificationRequestEventContent , MessageType , NoticeMessageEventContent , Relation , RoomMessageEventContent , TextMessageEventContent , VideoMessageEventContent } , AnyMessageLikeEvent , AnyMessageLikeEventContent , AnyStateEventContent , AnyTimelineEvent , FullStateEventContent } , uint, EventId , MilliSecondsSinceUnixEpoch , OwnedRoomId , OwnedUserId , UserId } ;
7
7
8
8
use crate :: { event_preview:: text_preview_of_other_state, shared:: room_filter_input_bar:: RoomFilterAction , sliding_sync:: { current_user_id, submit_async_request, MatrixRequest } , utils:: unix_time_millis_to_datetime} ;
@@ -40,14 +40,14 @@ live_design! {
40
40
text_style: <MESSAGE_TEXT_STYLE > { font_size: 10 } ,
41
41
color: ( TIMESTAMP_TEXT_COLOR )
42
42
}
43
- text: "Loading earlier messages ..."
43
+ text: "Loading search results ..."
44
44
}
45
45
}
46
46
SearchIcon = <Icon > {
47
47
align: { x: 0.0 } // Align to top-right
48
48
spacing: 10 ,
49
49
margin: { top: 0 , left: 10 } ,
50
- padding: { top : 10 , bottom : 10 , left : 8 , right : 15 }
50
+ padding: 10 ,
51
51
width: Fit ,
52
52
height: Fit ,
53
53
draw_bg: {
@@ -130,14 +130,16 @@ live_design! {
130
130
text: "Search All Rooms"
131
131
}
132
132
cancel_button = <RobrixIconButton > {
133
- align: { x: 1.0 }
134
- margin: { right: 10 , top: 0 } ,
135
133
width: Fit ,
136
- height: 32 ,
137
- padding: { left: 15 , right: 15 }
134
+ height: Fit ,
135
+ padding: 10 ,
136
+ spacing: 0 ,
137
+ margin: { left: 0 , right: 15 , top: -2 } ,
138
+
138
139
draw_bg: {
139
140
border_color: ( COLOR_DANGER_RED ) ,
140
141
color: #fff0f0 // light red
142
+ border_radius: 5
141
143
}
142
144
draw_icon: {
143
145
svg_file: ( ICON_CLOSE ) ,
@@ -302,8 +304,8 @@ pub fn search_result_draw_walk(room_screen: &mut RoomScreen, cx: &mut Cx2d, scop
302
304
continue ;
303
305
} ;
304
306
let item_drawn_status = ItemDrawnStatus {
305
- content_drawn : tl_state. content_drawn_since_last_update . contains ( & tl_idx) ,
306
- profile_drawn : tl_state. profile_drawn_since_last_update . contains ( & tl_idx) ,
307
+ content_drawn : tl_state. search_result_state . content_drawn_since_last_update . contains ( & tl_idx) ,
308
+ profile_drawn : tl_state. search_result_state . profile_drawn_since_last_update . contains ( & tl_idx) ,
307
309
} ;
308
310
let ( item, item_new_draw_status) = {
309
311
let current_item = timeline_item;
@@ -329,8 +331,9 @@ pub fn search_result_draw_walk(room_screen: &mut RoomScreen, cx: &mut Cx2d, scop
329
331
content = replace. original_content ( ) ;
330
332
}
331
333
match content {
332
- Some ( AnyMessageLikeEventContent :: RoomMessage ( mut message) ) => {
334
+ Some ( AnyMessageLikeEventContent :: RoomMessage ( message) ) => {
333
335
let mut in_reply_to_details = None ;
336
+ let mut message = message. clone ( ) ;
334
337
if let Some ( relation) = & message. relates_to {
335
338
match relation {
336
339
Relation :: Replacement ( replace) => {
@@ -344,6 +347,7 @@ pub fn search_result_draw_walk(room_screen: &mut RoomScreen, cx: &mut Cx2d, scop
344
347
}
345
348
}
346
349
let is_contextual = matches ! ( & current_item, SearchTimelineItem :: ContextEvent ( _) ) ;
350
+
347
351
if let MessageType :: Text ( text) = & mut message. msgtype {
348
352
if let Some ( ref mut formatted) = text. formatted {
349
353
for highlight in tl_state. search_result_state . highlighted_strings . iter ( ) {
@@ -357,7 +361,7 @@ pub fn search_result_draw_walk(room_screen: &mut RoomScreen, cx: &mut Cx2d, scop
357
361
text. formatted = Some ( FormattedBody :: html ( formated_string) ) ;
358
362
}
359
363
}
360
- let event = & EventableWrapperAEI ( event) ;
364
+ let event = & EventableWrapperAEI ( event, & tl_state . search_result_state . profiles_info ) ;
361
365
// Do not use compact view if previous event is state
362
366
let prev_event = prev_event. and_then ( |f| if matches ! ( f, AnyTimelineEvent :: State ( _) ) { None } else { Some ( f) } ) . map ( PreviousWrapperAEI ) ;
363
367
let message = MsgTypeWrapperRMC ( & message, in_reply_to_details. as_ref ( ) ) ;
@@ -377,7 +381,7 @@ pub fn search_result_draw_walk(room_screen: &mut RoomScreen, cx: &mut Cx2d, scop
377
381
)
378
382
}
379
383
Some ( AnyMessageLikeEventContent :: Sticker ( sticker) ) => {
380
- let event = & EventableWrapperAEI ( event) ;
384
+ let event = & EventableWrapperAEI ( event, & tl_state . search_result_state . profiles_info ) ;
381
385
let prev_event = prev_event. map ( PreviousWrapperAEI ) ;
382
386
let is_contextual = matches ! ( & current_item, SearchTimelineItem :: ContextEvent ( _) ) ;
383
387
populate_message_view (
@@ -405,7 +409,7 @@ pub fn search_result_draw_walk(room_screen: &mut RoomScreen, cx: &mut Cx2d, scop
405
409
let state_key = state. state_key ( ) ;
406
410
if let Some ( content) = state. original_content ( ) {
407
411
let wrapper = AnyStateEventContentWrapper ( & content, state_key) ;
408
- let event = & EventableWrapperAEI ( event) ;
412
+ let event = & EventableWrapperAEI ( event, & tl_state . search_result_state . profiles_info ) ;
409
413
populate_small_state_event (
410
414
cx,
411
415
list,
@@ -430,10 +434,10 @@ pub fn search_result_draw_walk(room_screen: &mut RoomScreen, cx: &mut Cx2d, scop
430
434
}
431
435
} ;
432
436
if item_new_draw_status. content_drawn {
433
- tl_state. content_drawn_since_last_update . insert ( tl_idx .. tl_idx + 1 ) ;
437
+ tl_state. search_result_state . content_drawn_since_last_update . insert ( tl_idx .. tl_idx + 1 ) ;
434
438
}
435
439
if item_new_draw_status. profile_drawn {
436
- tl_state. profile_drawn_since_last_update . insert ( tl_idx .. tl_idx + 1 ) ;
440
+ tl_state. search_result_state . profile_drawn_since_last_update . insert ( tl_idx .. tl_idx + 1 ) ;
437
441
}
438
442
item
439
443
} ;
@@ -524,11 +528,9 @@ pub fn search_result_reply(cx: &mut Cx, room_screen: &RoomScreen, details: &Mess
524
528
for ( index, item) in tl. items . iter ( ) . enumerate ( ) {
525
529
if item. as_event ( ) . and_then ( |f| f. event_id ( ) ) . map ( |f|Some ( f. to_owned ( ) ) == details. event_id ) . unwrap_or ( false ) {
526
530
timeline_details. item_id = index;
527
- println ! ( "index: {}" , index) ;
528
531
break ;
529
532
}
530
533
}
531
- println ! ( "search_result_reply detail{:?}" , timeline_details) ;
532
534
room_screen. view ( id ! ( search_timeline) ) . set_visible ( cx, false ) ;
533
535
cx. widget_action ( room_screen. widget_uid ( ) , & Scope :: empty ( ) . path , RoomFilterAction :: Clear ) ;
534
536
cx. widget_action (
@@ -594,7 +596,7 @@ impl <'a>From<&AnyStateEventContentWrapper<'a>> for Option<AnyOtherFullStateEven
594
596
}
595
597
}
596
598
}
597
- pub struct EventableWrapperAEI < ' a > ( pub & ' a AnyTimelineEvent ) ;
599
+ pub struct EventableWrapperAEI < ' a > ( pub & ' a AnyTimelineEvent , pub & ' a BTreeMap < OwnedUserId , TimelineDetails < Profile > > ) ;
598
600
599
601
impl Eventable for EventableWrapperAEI < ' _ > {
600
602
fn timestamp ( & self ) -> MilliSecondsSinceUnixEpoch {
@@ -606,8 +608,8 @@ impl Eventable for EventableWrapperAEI<'_> {
606
608
fn sender ( & self ) -> & UserId {
607
609
self . 0 . sender ( )
608
610
}
609
- fn sender_profile ( & self ) -> Option < & TimelineDetails < matrix_sdk_ui :: timeline :: Profile > > {
610
- None
611
+ fn sender_profile ( & self ) -> Option < & TimelineDetails < Profile > > {
612
+ self . 1 . get ( self . sender ( ) )
611
613
}
612
614
fn reactions ( & self ) -> Option < ReactionsByKeyBySender > {
613
615
None
0 commit comments