@@ -4343,7 +4343,7 @@ pub async fn forward_msgs(context: &Context, msg_ids: &[MsgId], chat_id: ChatId)
4343
4343
. sql
4344
4344
. query_get_value ( "SELECT timestamp FROM msgs WHERE id=?" , ( id, ) )
4345
4345
. await ?
4346
- . context ( "No message {id}" ) ?;
4346
+ . with_context ( || format ! ( "No message {id}" ) ) ?;
4347
4347
msgs. push ( ( ts, * id) ) ;
4348
4348
}
4349
4349
msgs. sort_unstable ( ) ;
@@ -4398,7 +4398,17 @@ pub async fn forward_msgs(context: &Context, msg_ids: &[MsgId], chat_id: ChatId)
4398
4398
/// Save a copy of the message in "Saved Messages"
4399
4399
/// and send a sync messages so that other devices save the message as well, unless deleted there.
4400
4400
pub async fn save_msgs ( context : & Context , msg_ids : & [ MsgId ] ) -> Result < ( ) > {
4401
- for src_msg_id in msg_ids {
4401
+ let mut msgs = Vec :: with_capacity ( msg_ids. len ( ) ) ;
4402
+ for id in msg_ids {
4403
+ let ts: i64 = context
4404
+ . sql
4405
+ . query_get_value ( "SELECT timestamp FROM msgs WHERE id=?" , ( id, ) )
4406
+ . await ?
4407
+ . with_context ( || format ! ( "No message {id}" ) ) ?;
4408
+ msgs. push ( ( ts, * id) ) ;
4409
+ }
4410
+ msgs. sort_unstable ( ) ;
4411
+ for ( _, src_msg_id) in msgs {
4402
4412
let dest_rfc724_mid = create_outgoing_rfc724_mid ( ) ;
4403
4413
let src_rfc724_mid = save_copy_in_self_talk ( context, src_msg_id, & dest_rfc724_mid) . await ?;
4404
4414
context
@@ -4419,11 +4429,11 @@ pub async fn save_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> {
4419
4429
/// Returns data needed to add a `SaveMessage` sync item.
4420
4430
pub ( crate ) async fn save_copy_in_self_talk (
4421
4431
context : & Context ,
4422
- src_msg_id : & MsgId ,
4432
+ src_msg_id : MsgId ,
4423
4433
dest_rfc724_mid : & String ,
4424
4434
) -> Result < String > {
4425
4435
let dest_chat_id = ChatId :: create_for_contact ( context, ContactId :: SELF ) . await ?;
4426
- let mut msg = Message :: load_from_db ( context, * src_msg_id) . await ?;
4436
+ let mut msg = Message :: load_from_db ( context, src_msg_id) . await ?;
4427
4437
msg. param . remove ( Param :: Cmd ) ;
4428
4438
msg. param . remove ( Param :: WebxdcDocument ) ;
4429
4439
msg. param . remove ( Param :: WebxdcDocumentTimestamp ) ;
@@ -4461,7 +4471,7 @@ pub(crate) async fn save_copy_in_self_talk(
4461
4471
. await ?;
4462
4472
let dest_msg_id = MsgId :: new ( row_id. try_into ( ) ?) ;
4463
4473
4464
- context. emit_msgs_changed ( msg. chat_id , * src_msg_id) ;
4474
+ context. emit_msgs_changed ( msg. chat_id , src_msg_id) ;
4465
4475
context. emit_msgs_changed ( dest_chat_id, dest_msg_id) ;
4466
4476
chatlist_events:: emit_chatlist_changed ( context) ;
4467
4477
chatlist_events:: emit_chatlist_item_changed ( context, dest_chat_id) ;
0 commit comments