Skip to content

Commit 2ce56fd

Browse files
authored
Merge pull request #593 from kevinaboos/fix_message_details_setting
just another cache invalidation bug, what else is new...
2 parents 9f97c5d + 491aab5 commit 2ce56fd

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/home/room_screen.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ impl RoomScreen {
21062106
MessageAction::JumpToRelated(details) => {
21072107
let Some(tl) = self.tl_state.as_mut() else { continue };
21082108
let Some(related_event_id) = details.related_event_id.as_ref() else {
2109-
error!("BUG: MessageAction::JumpToRelated had not related event ID.");
2109+
error!("BUG: MessageAction::JumpToRelated had no related event ID.\n{details:#?}");
21102110
continue;
21112111
};
21122112
let tl_idx = details.item_id;
@@ -3447,9 +3447,9 @@ fn populate_message_view(
34473447
}
34483448
};
34493449

3450-
let mut replied_to_event_id = None;
3451-
3452-
// If we didn't use a cached item, we need to draw all other message content: the reply preview and reactions.
3450+
// If we didn't use a cached item, we need to draw all other message content:
3451+
// the reactions, the read receipts avatar row, and the reply preview.
3452+
// We also must set the message details/metadata for the `item` widget representing this message.
34533453
if !used_cached_item {
34543454
item.reaction_list(id!(content.reaction_list)).set_list(
34553455
cx,
@@ -3458,16 +3458,31 @@ fn populate_message_view(
34583458
event_tl_item.identifier(),
34593459
item_id,
34603460
);
3461-
34623461
populate_read_receipts(&item, cx, room_id, event_tl_item);
3463-
let (is_reply_fully_drawn, replied_to_ev_id) = draw_replied_to_message(
3462+
let (is_reply_fully_drawn, replied_to_event_id) = draw_replied_to_message(
34643463
cx,
34653464
&item.view(id!(replied_to_message)),
34663465
room_id,
34673466
msg_like_content.in_reply_to.as_ref(),
34683467
event_tl_item.event_id(),
34693468
);
3470-
replied_to_event_id = replied_to_ev_id;
3469+
3470+
// Set the Message widget's metadata for reply-handling purposes.
3471+
let message_details = MessageDetails {
3472+
event_id: event_tl_item.event_id().map(|id| id.to_owned()),
3473+
item_id,
3474+
related_event_id: replied_to_event_id,
3475+
room_screen_widget_uid,
3476+
abilities: MessageAbilities::from_user_power_and_event(
3477+
user_power_levels,
3478+
event_tl_item,
3479+
msg_like_content,
3480+
has_html_body,
3481+
),
3482+
should_be_highlighted: event_tl_item.is_highlighted(),
3483+
};
3484+
item.as_message().set_data(message_details);
3485+
34713486
// The content is only considered to be fully drawn if the logic above marked it as such
34723487
// *and* if the reply preview was also fully drawn.
34733488
new_drawn_status.content_drawn &= is_reply_fully_drawn;
@@ -3484,7 +3499,6 @@ fn populate_message_view(
34843499
let username_label = item.label(id!(content.username));
34853500

34863501
if !is_server_notice { // the normal case
3487-
34883502
let (username, profile_drawn) = set_username_and_get_avatar_retval.unwrap_or_else(||
34893503
item.avatar(id!(profile.avatar)).set_avatar_and_get_username(
34903504
cx,
@@ -3523,26 +3537,12 @@ fn populate_message_view(
35233537
return (item, new_drawn_status);
35243538
}
35253539

3526-
// Set the Message widget's metadata for reply-handling purposes.
3527-
item.as_message().set_data(MessageDetails {
3528-
event_id: event_tl_item.event_id().map(|id| id.to_owned()),
3529-
item_id,
3530-
related_event_id: replied_to_event_id,
3531-
room_screen_widget_uid,
3532-
abilities: MessageAbilities::from_user_power_and_event(
3533-
user_power_levels,
3534-
event_tl_item,
3535-
msg_like_content,
3536-
has_html_body,
3537-
),
3538-
should_be_highlighted: event_tl_item.is_highlighted()
3539-
});
3540-
35413540
// Set the timestamp.
35423541
if let Some(dt) = unix_time_millis_to_datetime(ts_millis) {
35433542
item.timestamp(id!(profile.timestamp)).set_date_time(cx, dt);
35443543
}
35453544

3545+
// Set the "edited" indicator if this message was edited.
35463546
if msg_like_content.as_message().is_some_and(|m| m.is_edited()) {
35473547
item.edited_indicator(id!(profile.edited_indicator)).set_latest_edit(
35483548
cx,

0 commit comments

Comments
 (0)