@@ -46,6 +46,7 @@ use crate::tools::{
46
46
create_smeared_timestamps, get_abs_path, gm2local_offset, improve_single_line_input,
47
47
smeared_time, strip_rtlo_characters, time, IsNoneOrEmpty ,
48
48
} ;
49
+ use crate :: ui_events;
49
50
use crate :: webxdc:: WEBXDC_SUFFIX ;
50
51
51
52
/// An chat item, such as a message or a marker.
@@ -309,10 +310,8 @@ impl ChatId {
309
310
}
310
311
} ;
311
312
context. emit_msgs_changed_without_ids ( ) ;
312
- context. emit_event ( EventType :: UIChatListChanged ) ;
313
- context. emit_event ( EventType :: UIChatListItemChanged {
314
- chat_id : Some ( chat_id) ,
315
- } ) ;
313
+ ui_events:: emit_chatlist_changed ( context) ;
314
+ ui_events:: emit_chatlist_item_changed ( context, chat_id) ;
316
315
Ok ( chat_id)
317
316
}
318
317
@@ -429,7 +428,7 @@ impl ChatId {
429
428
}
430
429
}
431
430
}
432
- context . emit_event ( EventType :: UIChatListChanged ) ;
431
+ ui_events :: emit_chatlist_changed ( context ) ;
433
432
434
433
if sync. into ( ) {
435
434
// NB: For a 1:1 chat this currently triggers `Contact::block()` on other devices.
@@ -452,6 +451,8 @@ impl ChatId {
452
451
pub ( crate ) async fn unblock_ex ( self , context : & Context , sync : sync:: Sync ) -> Result < ( ) > {
453
452
self . set_blocked ( context, Blocked :: Not ) . await ?;
454
453
454
+ ui_events:: emit_chatlist_changed ( context) ;
455
+
455
456
if sync. into ( ) {
456
457
let chat = Chat :: load_from_db ( context, self ) . await ?;
457
458
// TODO: For a 1:1 chat this currently triggers `Contact::unblock()` on other devices.
@@ -461,9 +462,8 @@ impl ChatId {
461
462
. await
462
463
. log_err ( context)
463
464
. ok ( ) ;
464
-
465
- context. emit_event ( EventType :: UIChatListChanged ) ;
466
465
}
466
+
467
467
Ok ( ( ) )
468
468
}
469
469
@@ -507,9 +507,7 @@ impl ChatId {
507
507
508
508
if self . set_blocked ( context, Blocked :: Not ) . await ? {
509
509
context. emit_event ( EventType :: ChatModified ( self ) ) ;
510
- context. emit_event ( EventType :: UIChatListItemChanged {
511
- chat_id : Some ( self ) ,
512
- } ) ;
510
+ ui_events:: emit_chatlist_item_changed ( context, self ) ;
513
511
}
514
512
515
513
if sync. into ( ) {
@@ -552,9 +550,7 @@ impl ChatId {
552
550
. await ?;
553
551
554
552
context. emit_event ( EventType :: ChatModified ( self ) ) ;
555
- context. emit_event ( EventType :: UIChatListItemChanged {
556
- chat_id : Some ( self ) ,
557
- } ) ;
553
+ ui_events:: emit_chatlist_item_changed ( context, self ) ;
558
554
559
555
// make sure, the receivers will get all keys
560
556
self . reset_gossiped_timestamp ( context) . await ?;
@@ -603,9 +599,7 @@ impl ChatId {
603
599
if protection_status_modified {
604
600
self . add_protection_msg ( context, protect, contact_id, timestamp_sort)
605
601
. await ?;
606
- context. emit_event ( EventType :: UIChatListItemChanged {
607
- chat_id : Some ( self ) ,
608
- } ) ;
602
+ ui_events:: emit_chatlist_item_changed ( context, self ) ;
609
603
}
610
604
Ok ( ( ) )
611
605
}
@@ -692,10 +686,8 @@ impl ChatId {
692
686
. await ?;
693
687
694
688
context. emit_msgs_changed_without_ids ( ) ;
695
- context. emit_event ( EventType :: UIChatListChanged ) ;
696
- context. emit_event ( EventType :: UIChatListItemChanged {
697
- chat_id : Some ( self ) ,
698
- } ) ;
689
+ ui_events:: emit_chatlist_changed ( context) ;
690
+ ui_events:: emit_chatlist_item_changed ( context, self ) ;
699
691
700
692
if sync. into ( ) {
701
693
let chat = Chat :: load_from_db ( context, self ) . await ?;
@@ -802,7 +794,7 @@ impl ChatId {
802
794
. await ?;
803
795
804
796
context. emit_msgs_changed_without_ids ( ) ;
805
- context . emit_event ( EventType :: UIChatListChanged ) ;
797
+ ui_events :: emit_chatlist_changed ( context ) ;
806
798
807
799
context. set_config ( Config :: LastHousekeeping , None ) . await ?;
808
800
context. scheduler . interrupt_inbox ( ) . await ;
@@ -812,7 +804,7 @@ impl ChatId {
812
804
msg. text = stock_str:: self_deleted_msg_body ( context) . await ;
813
805
add_device_msg ( context, None , Some ( & mut msg) ) . await ?;
814
806
}
815
- context . emit_event ( EventType :: UIChatListChanged ) ;
807
+ ui_events :: emit_chatlist_changed ( context ) ;
816
808
817
809
Ok ( ( ) )
818
810
}
@@ -3115,13 +3107,9 @@ pub async fn marknoticed_chat(context: &Context, chat_id: ChatId) -> Result<()>
3115
3107
. await ?;
3116
3108
for chat_id_in_archive in chat_ids_in_archive {
3117
3109
context. emit_event ( EventType :: MsgsNoticed ( chat_id_in_archive) ) ;
3118
- context. emit_event ( EventType :: UIChatListItemChanged {
3119
- chat_id : Some ( chat_id_in_archive) ,
3120
- } ) ;
3110
+ ui_events:: emit_chatlist_item_changed ( context, chat_id_in_archive) ;
3121
3111
}
3122
- context. emit_event ( EventType :: UIChatListItemChanged {
3123
- chat_id : Some ( DC_CHAT_ID_ARCHIVED_LINK ) ,
3124
- } ) ;
3112
+ ui_events:: emit_chatlist_item_changed ( context, DC_CHAT_ID_ARCHIVED_LINK ) ;
3125
3113
} else {
3126
3114
let exists = context
3127
3115
. sql
@@ -3148,9 +3136,7 @@ pub async fn marknoticed_chat(context: &Context, chat_id: ChatId) -> Result<()>
3148
3136
}
3149
3137
3150
3138
context. emit_event ( EventType :: MsgsNoticed ( chat_id) ) ;
3151
- context. emit_event ( EventType :: UIChatListItemChanged {
3152
- chat_id : Some ( chat_id) ,
3153
- } ) ;
3139
+ ui_events:: emit_chatlist_item_changed ( context, chat_id) ;
3154
3140
3155
3141
Ok ( ( ) )
3156
3142
}
@@ -3218,7 +3204,7 @@ pub(crate) async fn mark_old_messages_as_noticed(
3218
3204
3219
3205
for c in changed_chats {
3220
3206
context. emit_event ( EventType :: MsgsNoticed ( c) ) ;
3221
- context . emit_event ( EventType :: UIChatListItemChanged { chat_id : Some ( c ) } ) ;
3207
+ ui_events :: emit_chatlist_item_changed ( context , c ) ;
3222
3208
}
3223
3209
3224
3210
Ok ( ( ) )
@@ -3381,10 +3367,8 @@ pub async fn create_group_chat(
3381
3367
}
3382
3368
3383
3369
context. emit_msgs_changed_without_ids ( ) ;
3384
- context. emit_event ( EventType :: UIChatListChanged ) ;
3385
- context. emit_event ( EventType :: UIChatListItemChanged {
3386
- chat_id : Some ( chat_id) ,
3387
- } ) ;
3370
+ ui_events:: emit_chatlist_changed ( context) ;
3371
+ ui_events:: emit_chatlist_item_changed ( context, chat_id) ;
3388
3372
3389
3373
if protect == ProtectionStatus :: Protected {
3390
3374
chat_id
@@ -3472,7 +3456,7 @@ pub(crate) async fn create_broadcast_list_ex(
3472
3456
let chat_id = ChatId :: new ( u32:: try_from ( row_id) ?) ;
3473
3457
3474
3458
context. emit_msgs_changed_without_ids ( ) ;
3475
- context . emit_event ( EventType :: UIChatListChanged ) ;
3459
+ ui_events :: emit_chatlist_changed ( context ) ;
3476
3460
3477
3461
if sync. into ( ) {
3478
3462
let id = SyncId :: Grpid ( grpid) ;
@@ -3750,9 +3734,7 @@ pub(crate) async fn set_muted_ex(
3750
3734
. await
3751
3735
. context ( format ! ( "Failed to set mute duration for {chat_id}" ) ) ?;
3752
3736
context. emit_event ( EventType :: ChatModified ( chat_id) ) ;
3753
- context. emit_event ( EventType :: UIChatListItemChanged {
3754
- chat_id : Some ( chat_id) ,
3755
- } ) ;
3737
+ ui_events:: emit_chatlist_item_changed ( context, chat_id) ;
3756
3738
if sync. into ( ) {
3757
3739
let chat = Chat :: load_from_db ( context, chat_id) . await ?;
3758
3740
chat. sync ( context, SyncAction :: SetMuted ( duration) )
@@ -3913,9 +3895,7 @@ async fn rename_ex(
3913
3895
sync = Nosync ;
3914
3896
}
3915
3897
context. emit_event ( EventType :: ChatModified ( chat_id) ) ;
3916
- context. emit_event ( EventType :: UIChatListItemChanged {
3917
- chat_id : Some ( chat_id) ,
3918
- } ) ;
3898
+ ui_events:: emit_chatlist_item_changed ( context, chat_id) ;
3919
3899
success = true ;
3920
3900
}
3921
3901
}
@@ -3976,9 +3956,7 @@ pub async fn set_chat_profile_image(
3976
3956
context. emit_msgs_changed ( chat_id, msg. id ) ;
3977
3957
}
3978
3958
context. emit_event ( EventType :: ChatModified ( chat_id) ) ;
3979
- context. emit_event ( EventType :: UIChatListItemChanged {
3980
- chat_id : Some ( chat_id) ,
3981
- } ) ;
3959
+ ui_events:: emit_chatlist_item_changed ( context, chat_id) ;
3982
3960
Ok ( ( ) )
3983
3961
}
3984
3962
@@ -4125,9 +4103,7 @@ pub async fn resend_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> {
4125
4103
msg_id : msg. id ,
4126
4104
} ) ;
4127
4105
// note(treefit): only matters if it is the last message in chat (but probably to expensive to check, debounce also solves it)
4128
- context. emit_event ( EventType :: UIChatListItemChanged {
4129
- chat_id : Some ( msg. chat_id ) ,
4130
- } ) ;
4106
+ ui_events:: emit_chatlist_item_changed ( context, msg. chat_id ) ;
4131
4107
if !create_send_msg_jobs ( context, & mut msg) . await ?. is_empty ( ) {
4132
4108
context. scheduler . interrupt_smtp ( ) . await ;
4133
4109
}
0 commit comments