Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ impl MatchEvent for App {

// Handle EventSourceModalAction to open/close the event source modal.
match action.downcast_ref() {
Some(EventSourceModalAction::Open { room_id, event_id, original_json }) => {
Some(EventSourceModalAction::Open { room_id, event_id, latest_json }) => {
self.ui.event_source_modal(cx, ids!(event_source_modal_inner))
.show(cx, room_id.clone(), event_id.clone(), original_json.clone());
.show(cx, room_id.clone(), event_id.clone(), latest_json.clone());
self.ui.modal(cx, ids!(event_source_modal)).open(cx);
continue;
}
Expand Down
18 changes: 9 additions & 9 deletions src/home/event_source_modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ script_mod! {
text_style: TITLE_TEXT {font_size: 13},
color: #000
}
text: "Original event source"
text: "Latest event source"
}

copy_source_button := mod.widgets.CopyButton {}
Expand Down Expand Up @@ -245,7 +245,7 @@ pub enum EventSourceModalAction {
Open {
room_id: OwnedRoomId,
event_id: Option<OwnedEventId>,
original_json: Option<String>,
latest_json: Option<String>,
},
/// Close the modal.
Close,
Expand All @@ -257,7 +257,7 @@ pub struct EventSourceModal {
#[deref] view: View,
#[rust] room_id: Option<OwnedRoomId>,
#[rust] event_id: Option<OwnedEventId>,
#[rust] original_json: Option<String>,
#[rust] latest_json: Option<String>,
}

impl Widget for EventSourceModal {
Expand All @@ -273,7 +273,7 @@ impl Widget for EventSourceModal {
if let Some(event_id) = &self.event_id {
self.view.label(cx, ids!(event_id_value)).set_text(cx, event_id.as_str());
}
if let Some(json) = &self.original_json {
if let Some(json) = &self.latest_json {
self.view.code_view(cx, ids!(code_view)).set_text(cx, json);
}
self.view.draw_walk(cx, scope, walk)
Expand Down Expand Up @@ -321,7 +321,7 @@ impl WidgetMatchEvent for EventSourceModal {
}

if self.view.button(cx, ids!(copy_source_button)).clicked(actions) {
if let Some(json) = &self.original_json {
if let Some(json) = &self.latest_json {
cx.copy_to_clipboard(json);
enqueue_popup_notification(
"Copied event source to clipboard.",
Expand All @@ -340,11 +340,11 @@ impl EventSourceModal {
cx: &mut Cx,
room_id: OwnedRoomId,
event_id: Option<OwnedEventId>,
original_json: Option<String>,
latest_json: Option<String>,
) {
self.room_id = Some(room_id.clone());
self.event_id = event_id.clone();
self.original_json = original_json.clone();
self.latest_json = latest_json.clone();

self.view.button(cx, ids!(close_button)).reset_hover(cx);
self.view.button(cx, ids!(room_id_copy_button)).reset_hover(cx);
Expand All @@ -361,9 +361,9 @@ impl EventSourceModalRef {
cx: &mut Cx,
room_id: OwnedRoomId,
event_id: Option<OwnedEventId>,
original_json: Option<String>,
latest_json: Option<String>,
) {
let Some(mut inner) = self.borrow_mut() else { return };
inner.show(cx, room_id, event_id, original_json);
inner.show(cx, room_id, event_id, latest_json);
}
}
8 changes: 4 additions & 4 deletions src/home/room_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2028,9 +2028,9 @@ impl RoomScreen {
);
continue;
};
// Get the original JSON from the event and pretty-print it
let original_json: Option<String> = event_tl_item
.original_json()
// Get the latest JSON from the event and pretty-print it
let latest_json: Option<String> = event_tl_item
.latest_json()
.and_then(|raw_event| serde_json::to_value(raw_event).ok())
.and_then(|value| serde_json::to_string_pretty(&value).ok());

Expand All @@ -2039,7 +2039,7 @@ impl RoomScreen {
cx.action(super::event_source_modal::EventSourceModalAction::Open {
room_id: tl.kind.room_id().clone(),
event_id,
original_json,
latest_json,
});
}
MessageAction::JumpToRelated(details) => {
Expand Down
Loading