Fix view source shows original event for an edited message (#377)
Signed-off-by: Clament John <cj@hackerlab.in> fixes #376 When we click view source for an edited message we were showing the original event (the unedited event) instead of the latest edited event.
This commit is contained in:
parent
6e9cd02b2b
commit
92a3a8d6fa
1 changed files with 13 additions and 1 deletions
|
@ -469,6 +469,18 @@ function isMedia(mE) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if editedTimeline has mEventId then pass editedMEvent else pass mEvent to openViewSource
|
||||||
|
function handleOpenViewSource(mEvent, roomTimeline) {
|
||||||
|
const eventId = mEvent.getId();
|
||||||
|
const { editedTimeline } = roomTimeline ?? {};
|
||||||
|
let editedMEvent;
|
||||||
|
if (editedTimeline?.has(eventId)) {
|
||||||
|
const editedList = editedTimeline.get(eventId);
|
||||||
|
editedMEvent = editedList[editedList.length - 1];
|
||||||
|
}
|
||||||
|
openViewSource(editedMEvent !== undefined ? editedMEvent : mEvent);
|
||||||
|
}
|
||||||
|
|
||||||
const MessageOptions = React.memo(({
|
const MessageOptions = React.memo(({
|
||||||
roomTimeline, mEvent, edit, reply,
|
roomTimeline, mEvent, edit, reply,
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -516,7 +528,7 @@ const MessageOptions = React.memo(({
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
iconSrc={CmdIC}
|
iconSrc={CmdIC}
|
||||||
onClick={() => openViewSource(mEvent)}
|
onClick={() => handleOpenViewSource(mEvent, roomTimeline)}
|
||||||
>
|
>
|
||||||
View source
|
View source
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|
Loading…
Reference in a new issue