@@ -10,15 +10,11 @@ use matrix_sdk::{
10
10
} ,
11
11
} ;
12
12
use matrix_sdk_ui:: timeline:: { EventTimelineItem , TimelineEventItemId , TimelineItemContent } ;
13
-
14
13
use crate :: {
15
14
shared:: popup_list:: enqueue_popup_notification,
16
15
sliding_sync:: { MatrixRequest , submit_async_request} ,
17
16
} ;
18
-
19
- use crate :: room:: room_member_manager:: { RoomMemberSubscriber , RoomMemberSubscription } ;
20
- use crate :: shared:: mentionable_text_input:: { MentionableTextInputWidgetExt , MentionableTextInputAction } ;
21
- use std:: sync:: { Arc , Mutex } ;
17
+ use crate :: shared:: mentionable_text_input:: MentionableTextInputWidgetExt ;
22
18
23
19
live_design ! {
24
20
use link:: theme:: * ;
@@ -167,52 +163,6 @@ struct EditingPaneInfo {
167
163
room_id : OwnedRoomId ,
168
164
}
169
165
170
- /// Actions specific to EditingPane for internal use
171
- #[ derive( Clone , Debug , DefaultNone ) ]
172
- enum EditingPaneInternalAction {
173
- /// Room members data has been updated
174
- RoomMembersUpdated ( Arc < Vec < matrix_sdk:: room:: RoomMember > > ) ,
175
- None ,
176
- }
177
-
178
- /// Subscriber for EditingPane to receive room member updates
179
- struct EditingPaneSubscriber {
180
- widget_uid : WidgetUid ,
181
- current_room_id : Option < OwnedRoomId > ,
182
- }
183
-
184
- /// Implement `RoomMemberSubscriber` trait, receive member update notifications
185
- impl RoomMemberSubscriber for EditingPaneSubscriber {
186
- fn on_room_members_updated (
187
- & mut self ,
188
- cx : & mut Cx ,
189
- room_id : & OwnedRoomId ,
190
- members : Arc < Vec < matrix_sdk:: room:: RoomMember > > ,
191
- ) {
192
- if let Some ( current_room_id) = & self . current_room_id {
193
- if current_room_id == room_id {
194
- // Log with stable identifier
195
- log ! (
196
- "EditingPaneSubscriber({:?}) received members update for room {}" ,
197
- self . widget_uid,
198
- room_id
199
- ) ;
200
-
201
- // cx.action(EditingPaneInternalAction::RoomMembersUpdated(members.clone()));
202
- cx. widget_action (
203
- self . widget_uid ,
204
- & Scope :: empty ( ) . path ,
205
- EditingPaneInternalAction :: RoomMembersUpdated ( members) ,
206
- ) ;
207
- } else {
208
- log ! ( "Ignoring update for different room {} (current: {})" , room_id, current_room_id) ;
209
- }
210
- }
211
-
212
-
213
- }
214
- }
215
-
216
166
/// A view that slides in from the bottom of the screen to allow editing a message.
217
167
#[ derive( Live , LiveHook , Widget ) ]
218
168
pub struct EditingPane {
@@ -225,8 +175,6 @@ pub struct EditingPane {
225
175
info : Option < EditingPaneInfo > ,
226
176
#[ rust]
227
177
is_animating_out : bool ,
228
- #[ rust]
229
- member_subscription : Option < RoomMemberSubscription > ,
230
178
}
231
179
232
180
impl Widget for EditingPane {
@@ -264,29 +212,6 @@ impl Widget for EditingPane {
264
212
if let Event :: Actions ( actions) = event {
265
213
let edit_text_input = self . mentionable_text_input ( id ! ( editing_content. edit_text_input) ) . text_input ( id ! ( text_input) ) ;
266
214
267
- // Check for room member update actions and power level updates
268
- for action in actions {
269
- // Check for MentionableTextInputAction::PowerLevelsUpdated
270
- if let Some ( MentionableTextInputAction :: PowerLevelsUpdated ( room_id, can_notify_room) ) = action. downcast_ref :: < MentionableTextInputAction > ( ) {
271
- // Make sure this is for our current room
272
- if let Some ( info) = & self . info {
273
- if & info. room_id == room_id {
274
- let message_input = self . mentionable_text_input ( id ! ( editing_content. edit_text_input) ) ;
275
- message_input. set_can_notify_room ( * can_notify_room) ;
276
- }
277
- }
278
- }
279
-
280
- if let Some ( widget_action) = action. as_widget_action ( ) . widget_uid_eq ( self . widget_uid ( ) ) {
281
- if let Some ( update_action) = widget_action. downcast_ref :: < EditingPaneInternalAction > ( ) {
282
- if let EditingPaneInternalAction :: RoomMembersUpdated ( members) = update_action {
283
- self . handle_members_updated ( members. clone ( ) ) ;
284
- }
285
- continue ;
286
- }
287
- }
288
- }
289
-
290
215
// Hide the editing pane if the cancel button was clicked
291
216
// or if the `Escape` key was pressed within the edit text input.
292
217
if self . button ( id ! ( cancel_button) ) . clicked ( actions)
@@ -492,7 +417,7 @@ impl EditingPane {
492
417
}
493
418
494
419
/// Shows the editing pane and sets it up to edit the given `event`'s content.
495
- pub fn show ( & mut self , cx : & mut Cx , event_tl_item : EventTimelineItem , room_id : OwnedRoomId ) {
420
+ pub fn show ( & mut self , cx : & mut Cx , event_tl_item : EventTimelineItem , room_id : OwnedRoomId , can_notify_room : bool ) {
496
421
if !event_tl_item. is_editable ( ) {
497
422
enqueue_popup_notification ( "That message cannot be edited." . into ( ) ) ;
498
423
return ;
@@ -501,6 +426,8 @@ impl EditingPane {
501
426
log ! ( "EditingPane show: Opening editing pane for room: {}" , room_id) ;
502
427
503
428
let edit_text_input = self . mentionable_text_input ( id ! ( editing_content. edit_text_input) ) ;
429
+ edit_text_input. set_can_notify_room ( can_notify_room) ;
430
+
504
431
match event_tl_item. content ( ) {
505
432
TimelineItemContent :: Message ( message) => {
506
433
edit_text_input. set_text ( cx, message. body ( ) ) ;
@@ -517,11 +444,9 @@ impl EditingPane {
517
444
self . info = Some ( EditingPaneInfo { event_tl_item, room_id : room_id. clone ( ) } ) ;
518
445
519
446
// Set room ID on the MentionableTextInput
520
- let edit_text_input = self . mentionable_text_input ( id ! ( editing_content. edit_text_input) ) ;
521
447
edit_text_input. set_room_id ( room_id. clone ( ) ) ;
522
-
523
448
// Create room member subscription
524
- self . create_room_subscription ( cx, room_id. clone ( ) ) ;
449
+ edit_text_input . create_room_subscription ( cx, room_id) ;
525
450
526
451
self . visible = true ;
527
452
self . button ( id ! ( accept_button) ) . reset_hover ( cx) ;
@@ -535,50 +460,6 @@ impl EditingPane {
535
460
self . animator_play ( cx, id ! ( panel. show) ) ;
536
461
self . redraw ( cx) ;
537
462
}
538
-
539
- /// Create room member subscription for the editing pane
540
- fn create_room_subscription ( & mut self , cx : & mut Cx , room_id : OwnedRoomId ) {
541
- // Cancel previous subscription if any
542
- self . member_subscription = None ;
543
-
544
- log ! ( "Creating room member subscription for EditingPane, ID: {:?}" , self . widget_uid( ) ) ;
545
-
546
- // Create new subscriber
547
- let subscriber = Arc :: new ( Mutex :: new ( EditingPaneSubscriber {
548
- widget_uid : self . widget_uid ( ) ,
549
- current_room_id : Some ( room_id. clone ( ) ) ,
550
- } ) ) ;
551
-
552
- // Create and save subscription
553
- self . member_subscription = Some ( RoomMemberSubscription :: new ( cx, room_id. clone ( ) , subscriber) ) ;
554
-
555
- submit_async_request ( MatrixRequest :: GetRoomMembers {
556
- room_id : room_id. clone ( ) ,
557
- memberships : matrix_sdk:: RoomMemberships :: JOIN ,
558
- local_only : false ,
559
- } ) ;
560
-
561
- // Request power levels data to determine if @room mentions are allowed
562
- submit_async_request ( MatrixRequest :: GetRoomPowerLevels {
563
- room_id,
564
- } ) ;
565
- }
566
-
567
- /// Handle room members update event
568
- fn handle_members_updated ( & mut self , members : Arc < Vec < matrix_sdk:: room:: RoomMember > > ) {
569
- if let Some ( _info) = & self . info {
570
- // Pass room member data to MentionableTextInput
571
- let message_input = self . mentionable_text_input ( id ! ( editing_content. edit_text_input) ) ;
572
- message_input. set_room_members ( members) ;
573
-
574
- // Also set room ID if it's not already set
575
- if let Some ( info) = & self . info {
576
- if message_input. get_room_id ( ) . is_none ( ) {
577
- message_input. set_room_id ( info. room_id . clone ( ) ) ;
578
- }
579
- }
580
- }
581
- }
582
463
}
583
464
584
465
impl EditingPaneRef {
@@ -604,11 +485,11 @@ impl EditingPaneRef {
604
485
}
605
486
606
487
/// See [`EditingPane::show()`].
607
- pub fn show ( & self , cx : & mut Cx , event_tl_item : EventTimelineItem , room_id : OwnedRoomId ) {
488
+ pub fn show ( & self , cx : & mut Cx , event_tl_item : EventTimelineItem , room_id : OwnedRoomId , can_notify_room : bool ) {
608
489
let Some ( mut inner) = self . borrow_mut ( ) else {
609
490
return ;
610
491
} ;
611
- inner. show ( cx, event_tl_item, room_id) ;
492
+ inner. show ( cx, event_tl_item, room_id, can_notify_room ) ;
612
493
}
613
494
614
495
/// Returns the event that is currently being edited, if any.
0 commit comments