@@ -45,6 +45,7 @@ use crate::tools::{
45
45
create_smeared_timestamps, get_abs_path, gm2local_offset, improve_single_line_input,
46
46
smeared_time, strip_rtlo_characters, time, IsNoneOrEmpty , SystemTime ,
47
47
} ;
48
+ use crate :: ui_events;
48
49
use crate :: webxdc:: WEBXDC_SUFFIX ;
49
50
50
51
/// An chat item, such as a message or a marker.
@@ -308,10 +309,8 @@ impl ChatId {
308
309
}
309
310
} ;
310
311
context. emit_msgs_changed_without_ids ( ) ;
311
- context. emit_event ( EventType :: UIChatListChanged ) ;
312
- context. emit_event ( EventType :: UIChatListItemChanged {
313
- chat_id : Some ( chat_id) ,
314
- } ) ;
312
+ ui_events:: emit_chatlist_changed ( context) ;
313
+ ui_events:: emit_chatlist_item_changed ( context, chat_id) ;
315
314
Ok ( chat_id)
316
315
}
317
316
@@ -428,7 +427,7 @@ impl ChatId {
428
427
}
429
428
}
430
429
}
431
- context . emit_event ( EventType :: UIChatListChanged ) ;
430
+ ui_events :: emit_chatlist_changed ( context ) ;
432
431
433
432
if sync. into ( ) {
434
433
// NB: For a 1:1 chat this currently triggers `Contact::block()` on other devices.
@@ -451,6 +450,8 @@ impl ChatId {
451
450
pub ( crate ) async fn unblock_ex ( self , context : & Context , sync : sync:: Sync ) -> Result < ( ) > {
452
451
self . set_blocked ( context, Blocked :: Not ) . await ?;
453
452
453
+ ui_events:: emit_chatlist_changed ( context) ;
454
+
454
455
if sync. into ( ) {
455
456
let chat = Chat :: load_from_db ( context, self ) . await ?;
456
457
// TODO: For a 1:1 chat this currently triggers `Contact::unblock()` on other devices.
@@ -460,9 +461,8 @@ impl ChatId {
460
461
. await
461
462
. log_err ( context)
462
463
. ok ( ) ;
463
-
464
- context. emit_event ( EventType :: UIChatListChanged ) ;
465
464
}
465
+
466
466
Ok ( ( ) )
467
467
}
468
468
@@ -506,9 +506,7 @@ impl ChatId {
506
506
507
507
if self . set_blocked ( context, Blocked :: Not ) . await ? {
508
508
context. emit_event ( EventType :: ChatModified ( self ) ) ;
509
- context. emit_event ( EventType :: UIChatListItemChanged {
510
- chat_id : Some ( self ) ,
511
- } ) ;
509
+ ui_events:: emit_chatlist_item_changed ( context, self ) ;
512
510
}
513
511
514
512
if sync. into ( ) {
@@ -551,9 +549,7 @@ impl ChatId {
551
549
. await ?;
552
550
553
551
context. emit_event ( EventType :: ChatModified ( self ) ) ;
554
- context. emit_event ( EventType :: UIChatListItemChanged {
555
- chat_id : Some ( self ) ,
556
- } ) ;
552
+ ui_events:: emit_chatlist_item_changed ( context, self ) ;
557
553
558
554
// make sure, the receivers will get all keys
559
555
self . reset_gossiped_timestamp ( context) . await ?;
@@ -602,9 +598,7 @@ impl ChatId {
602
598
if protection_status_modified {
603
599
self . add_protection_msg ( context, protect, contact_id, timestamp_sort)
604
600
. await ?;
605
- context. emit_event ( EventType :: UIChatListItemChanged {
606
- chat_id : Some ( self ) ,
607
- } ) ;
601
+ ui_events:: emit_chatlist_item_changed ( context, self ) ;
608
602
}
609
603
Ok ( ( ) )
610
604
}
@@ -691,10 +685,8 @@ impl ChatId {
691
685
. await ?;
692
686
693
687
context. emit_msgs_changed_without_ids ( ) ;
694
- context. emit_event ( EventType :: UIChatListChanged ) ;
695
- context. emit_event ( EventType :: UIChatListItemChanged {
696
- chat_id : Some ( self ) ,
697
- } ) ;
688
+ ui_events:: emit_chatlist_changed ( context) ;
689
+ ui_events:: emit_chatlist_item_changed ( context, self ) ;
698
690
699
691
if sync. into ( ) {
700
692
let chat = Chat :: load_from_db ( context, self ) . await ?;
@@ -801,7 +793,7 @@ impl ChatId {
801
793
. await ?;
802
794
803
795
context. emit_msgs_changed_without_ids ( ) ;
804
- context . emit_event ( EventType :: UIChatListChanged ) ;
796
+ ui_events :: emit_chatlist_changed ( context ) ;
805
797
806
798
context
807
799
. set_config_internal ( Config :: LastHousekeeping , None )
@@ -813,7 +805,7 @@ impl ChatId {
813
805
msg. text = stock_str:: self_deleted_msg_body ( context) . await ;
814
806
add_device_msg ( context, None , Some ( & mut msg) ) . await ?;
815
807
}
816
- context . emit_event ( EventType :: UIChatListChanged ) ;
808
+ ui_events :: emit_chatlist_changed ( context ) ;
817
809
818
810
Ok ( ( ) )
819
811
}
@@ -3118,13 +3110,9 @@ pub async fn marknoticed_chat(context: &Context, chat_id: ChatId) -> Result<()>
3118
3110
. await ?;
3119
3111
for chat_id_in_archive in chat_ids_in_archive {
3120
3112
context. emit_event ( EventType :: MsgsNoticed ( chat_id_in_archive) ) ;
3121
- context. emit_event ( EventType :: UIChatListItemChanged {
3122
- chat_id : Some ( chat_id_in_archive) ,
3123
- } ) ;
3113
+ ui_events:: emit_chatlist_item_changed ( context, chat_id_in_archive) ;
3124
3114
}
3125
- context. emit_event ( EventType :: UIChatListItemChanged {
3126
- chat_id : Some ( DC_CHAT_ID_ARCHIVED_LINK ) ,
3127
- } ) ;
3115
+ ui_events:: emit_chatlist_item_changed ( context, DC_CHAT_ID_ARCHIVED_LINK ) ;
3128
3116
} else {
3129
3117
let exists = context
3130
3118
. sql
@@ -3151,9 +3139,7 @@ pub async fn marknoticed_chat(context: &Context, chat_id: ChatId) -> Result<()>
3151
3139
}
3152
3140
3153
3141
context. emit_event ( EventType :: MsgsNoticed ( chat_id) ) ;
3154
- context. emit_event ( EventType :: UIChatListItemChanged {
3155
- chat_id : Some ( chat_id) ,
3156
- } ) ;
3142
+ ui_events:: emit_chatlist_item_changed ( context, chat_id) ;
3157
3143
3158
3144
Ok ( ( ) )
3159
3145
}
@@ -3221,7 +3207,7 @@ pub(crate) async fn mark_old_messages_as_noticed(
3221
3207
3222
3208
for c in changed_chats {
3223
3209
context. emit_event ( EventType :: MsgsNoticed ( c) ) ;
3224
- context . emit_event ( EventType :: UIChatListItemChanged { chat_id : Some ( c ) } ) ;
3210
+ ui_events :: emit_chatlist_item_changed ( context , c ) ;
3225
3211
}
3226
3212
3227
3213
Ok ( ( ) )
@@ -3384,10 +3370,8 @@ pub async fn create_group_chat(
3384
3370
}
3385
3371
3386
3372
context. emit_msgs_changed_without_ids ( ) ;
3387
- context. emit_event ( EventType :: UIChatListChanged ) ;
3388
- context. emit_event ( EventType :: UIChatListItemChanged {
3389
- chat_id : Some ( chat_id) ,
3390
- } ) ;
3373
+ ui_events:: emit_chatlist_changed ( context) ;
3374
+ ui_events:: emit_chatlist_item_changed ( context, chat_id) ;
3391
3375
3392
3376
if protect == ProtectionStatus :: Protected {
3393
3377
chat_id
@@ -3475,7 +3459,7 @@ pub(crate) async fn create_broadcast_list_ex(
3475
3459
let chat_id = ChatId :: new ( u32:: try_from ( row_id) ?) ;
3476
3460
3477
3461
context. emit_msgs_changed_without_ids ( ) ;
3478
- context . emit_event ( EventType :: UIChatListChanged ) ;
3462
+ ui_events :: emit_chatlist_changed ( context ) ;
3479
3463
3480
3464
if sync. into ( ) {
3481
3465
let id = SyncId :: Grpid ( grpid) ;
@@ -3753,9 +3737,7 @@ pub(crate) async fn set_muted_ex(
3753
3737
. await
3754
3738
. context ( format ! ( "Failed to set mute duration for {chat_id}" ) ) ?;
3755
3739
context. emit_event ( EventType :: ChatModified ( chat_id) ) ;
3756
- context. emit_event ( EventType :: UIChatListItemChanged {
3757
- chat_id : Some ( chat_id) ,
3758
- } ) ;
3740
+ ui_events:: emit_chatlist_item_changed ( context, chat_id) ;
3759
3741
if sync. into ( ) {
3760
3742
let chat = Chat :: load_from_db ( context, chat_id) . await ?;
3761
3743
chat. sync ( context, SyncAction :: SetMuted ( duration) )
@@ -3916,9 +3898,7 @@ async fn rename_ex(
3916
3898
sync = Nosync ;
3917
3899
}
3918
3900
context. emit_event ( EventType :: ChatModified ( chat_id) ) ;
3919
- context. emit_event ( EventType :: UIChatListItemChanged {
3920
- chat_id : Some ( chat_id) ,
3921
- } ) ;
3901
+ ui_events:: emit_chatlist_item_changed ( context, chat_id) ;
3922
3902
success = true ;
3923
3903
}
3924
3904
}
@@ -3979,9 +3959,7 @@ pub async fn set_chat_profile_image(
3979
3959
context. emit_msgs_changed ( chat_id, msg. id ) ;
3980
3960
}
3981
3961
context. emit_event ( EventType :: ChatModified ( chat_id) ) ;
3982
- context. emit_event ( EventType :: UIChatListItemChanged {
3983
- chat_id : Some ( chat_id) ,
3984
- } ) ;
3962
+ ui_events:: emit_chatlist_item_changed ( context, chat_id) ;
3985
3963
Ok ( ( ) )
3986
3964
}
3987
3965
@@ -4129,9 +4107,7 @@ pub async fn resend_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> {
4129
4107
} ) ;
4130
4108
msg. timestamp_sort = create_smeared_timestamp ( context) ;
4131
4109
// note(treefit): only matters if it is the last message in chat (but probably to expensive to check, debounce also solves it)
4132
- context. emit_event ( EventType :: UIChatListItemChanged {
4133
- chat_id : Some ( msg. chat_id ) ,
4134
- } ) ;
4110
+ ui_events:: emit_chatlist_item_changed ( context, msg. chat_id ) ;
4135
4111
if !create_send_msg_jobs ( context, & mut msg) . await ?. is_empty ( ) {
4136
4112
context. scheduler . interrupt_smtp ( ) . await ;
4137
4113
}
0 commit comments