room-history: Update event actions when its source changes

This commit is contained in:
Kévin Commaille 2022-09-15 17:13:00 +02:00
parent 0b8d78c7e3
commit 454bb4e5e4
No known key found for this signature in database
GPG key ID: DD507DAE96E8245C
2 changed files with 7 additions and 7 deletions

View file

@ -222,15 +222,15 @@ impl ItemRow {
if let Some(ref item) = item {
if let Some(event) = item.downcast_ref::<SupportedEvent>() {
self.set_action_group(self.set_event_actions(Some(event.upcast_ref())));
let notify_handler =
event.connect_pure_event_notify(clone!(@weak self as obj => move |event| {
event.connect_source_notify(clone!(@weak self as obj => move |event| {
obj.set_event_widget(event);
obj.set_action_group(obj.set_event_actions(Some(event.upcast_ref())));
}));
priv_.notify_handler.replace(Some(notify_handler));
self.set_event_widget(event);
self.set_action_group(self.set_event_actions(Some(event.upcast_ref())));
} else if let Some(divider) = item.downcast_ref::<TimelineDayDivider>() {
self.set_popover(None);
self.set_action_group(None);

View file

@ -98,7 +98,7 @@ mod imp {
"Source",
"The JSON source of this Event",
None,
glib::ParamFlags::READABLE | glib::ParamFlags::EXPLICIT_NOTIFY,
glib::ParamFlags::READABLE,
),
glib::ParamSpecObject::new(
"room",
@ -243,7 +243,7 @@ pub trait EventExt: 'static {
Some(time)
}
fn connect_pure_event_notify<F: Fn(&Self) + 'static>(&self, f: F) -> glib::SignalHandlerId;
fn connect_source_notify<F: Fn(&Self) + 'static>(&self, f: F) -> glib::SignalHandlerId;
}
impl<O: IsA<Event>> EventExt for O {
@ -298,8 +298,8 @@ impl<O: IsA<Event>> EventExt for O {
imp::event_origin_server_ts(self.upcast_ref())
}
fn connect_pure_event_notify<F: Fn(&Self) + 'static>(&self, f: F) -> glib::SignalHandlerId {
self.connect_notify_local(Some("pure-event"), move |this, _| {
fn connect_source_notify<F: Fn(&Self) + 'static>(&self, f: F) -> glib::SignalHandlerId {
self.connect_notify_local(Some("source"), move |this, _| {
f(this);
})
}