@@ -831,10 +831,10 @@ pub enum EventLocation {
831831
832832impl EventLocation {
833833 fn to_message_key ( & self ) -> Option < & MessageKey > {
834- if let EventLocation :: Message ( _ , key ) = self {
835- Some ( key)
836- } else {
837- None
834+ match self {
835+ EventLocation :: Message ( _ , key ) => Some ( key) ,
836+ EventLocation :: Sticker ( key ) => Some ( key ) ,
837+ _ => None ,
838838 }
839839 }
840840}
@@ -1074,18 +1074,41 @@ impl RoomInfo {
10741074 }
10751075
10761076 /// Insert a sticker
1077- pub fn insert_sticker ( & mut self , sticker : StickerEvent ) {
1077+ pub fn insert_sticker (
1078+ & mut self ,
1079+ room_id : OwnedRoomId ,
1080+ store : AsyncProgramStore ,
1081+ picker : Option < Picker > ,
1082+ sticker : StickerEvent ,
1083+ settings : & mut ApplicationSettings ,
1084+ media : matrix_sdk:: Media ,
1085+ ) {
10781086 match sticker {
10791087 MessageLikeEvent :: Original ( ref sticker_content) => {
1080- //TODO
10811088 let key =
10821089 ( sticker_content. origin_server_ts . into ( ) , sticker_content. event_id . clone ( ) ) ;
10831090
10841091 let loc = EventLocation :: Sticker ( key. clone ( ) ) ;
10851092
10861093 self . keys . insert ( sticker_content. event_id . clone ( ) , loc) ;
1087-
1088- self . messages . insert_message ( key, sticker) ;
1094+ self . messages . insert_message ( key. clone ( ) , sticker. clone ( ) ) ;
1095+
1096+ if picker. is_some ( ) {
1097+ if let ( Some ( msg) , Some ( image_preview) ) = (
1098+ self . get_event_mut ( & sticker_content. event_id ) ,
1099+ & settings. tunables . image_preview ,
1100+ ) {
1101+ msg. image_preview = ImageStatus :: Downloading ( image_preview. size . clone ( ) ) ;
1102+ spawn_insert_preview (
1103+ store,
1104+ room_id,
1105+ sticker_content. event_id . clone ( ) ,
1106+ sticker_content. content . source . clone ( ) . into ( ) ,
1107+ media,
1108+ settings. dirs . image_previews . clone ( ) ,
1109+ )
1110+ }
1111+ }
10891112 } ,
10901113 MessageLikeEvent :: Redacted ( _) => {
10911114 return ;
0 commit comments