Fix sending localEvent id to redact and reply (#231)
Signed-off-by: ajbura <ajbura@gmail.com>
This commit is contained in:
parent
bb99167433
commit
101abaeda1
1 changed files with 29 additions and 21 deletions
|
@ -114,6 +114,7 @@ const MessageReplyWrapper = React.memo(({ roomTimeline, eventId }) => {
|
|||
const mx = initMatrix.matrixClient;
|
||||
const timelineSet = roomTimeline.getUnfilteredTimelineSet();
|
||||
const loadReply = async () => {
|
||||
try {
|
||||
const eTimeline = await mx.getEventTimeline(timelineSet, eventId);
|
||||
await roomTimeline.decryptAllEventsOfTimeline(eTimeline);
|
||||
|
||||
|
@ -123,13 +124,21 @@ const MessageReplyWrapper = React.memo(({ roomTimeline, eventId }) => {
|
|||
const username = getUsernameOfRoomMember(mEvent.sender);
|
||||
|
||||
if (isMountedRef.current === false) return;
|
||||
const fallbackBody = mEvent.isRedacted() ? '*** This message has been deleted ***' : '*** Unable to load reply content ***';
|
||||
const fallbackBody = mEvent.isRedacted() ? '*** This message has been deleted ***' : '*** Unable to load reply ***';
|
||||
setReply({
|
||||
to: username,
|
||||
color: colorMXID(mEvent.getSender()),
|
||||
body: parseReply(rawBody)?.body ?? rawBody ?? fallbackBody,
|
||||
event: mEvent,
|
||||
});
|
||||
} catch {
|
||||
setReply({
|
||||
to: '** Unknown user **',
|
||||
color: 'var(--tc-danger-normal)',
|
||||
body: '*** Unable to load reply ***',
|
||||
event: null,
|
||||
});
|
||||
}
|
||||
};
|
||||
loadReply();
|
||||
|
||||
|
@ -139,6 +148,7 @@ const MessageReplyWrapper = React.memo(({ roomTimeline, eventId }) => {
|
|||
}, []);
|
||||
|
||||
const focusReply = () => {
|
||||
if (reply?.event === null) return;
|
||||
if (reply?.event.isRedacted()) return;
|
||||
roomTimeline.loadEventTimeline(eventId);
|
||||
};
|
||||
|
@ -357,13 +367,12 @@ MessageReaction.propTypes = {
|
|||
|
||||
function MessageReactionGroup({ roomTimeline, mEvent }) {
|
||||
const { roomId, room, reactionTimeline } = roomTimeline;
|
||||
const eventId = mEvent.getId();
|
||||
const mx = initMatrix.matrixClient;
|
||||
const reactions = {};
|
||||
const shortcodeToEmoji = getShortcodeToCustomEmoji(room);
|
||||
const canSendReaction = room.currentState.maySendEvent('m.reaction', mx.getUserId());
|
||||
|
||||
const eventReactions = reactionTimeline.get(eventId);
|
||||
const eventReactions = reactionTimeline.get(mEvent.getId());
|
||||
const addReaction = (key, count, senderId, isActive) => {
|
||||
let reaction = reactions[key];
|
||||
if (reaction === undefined) {
|
||||
|
@ -414,7 +423,7 @@ function MessageReactionGroup({ roomTimeline, mEvent }) {
|
|||
users={reactions[key].users}
|
||||
isActive={reactions[key].isActive}
|
||||
onClick={() => {
|
||||
toggleEmoji(roomId, eventId, key, roomTimeline);
|
||||
toggleEmoji(roomId, mEvent.getId(), key, roomTimeline);
|
||||
}}
|
||||
/>
|
||||
))
|
||||
|
@ -422,7 +431,7 @@ function MessageReactionGroup({ roomTimeline, mEvent }) {
|
|||
{canSendReaction && (
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
pickEmoji(e, roomId, eventId, roomTimeline);
|
||||
pickEmoji(e, roomId, mEvent.getId(), roomTimeline);
|
||||
}}
|
||||
src={EmojiAddIC}
|
||||
size="extra-small"
|
||||
|
@ -452,7 +461,6 @@ const MessageOptions = React.memo(({
|
|||
}) => {
|
||||
const { roomId, room } = roomTimeline;
|
||||
const mx = initMatrix.matrixClient;
|
||||
const eventId = mEvent.getId();
|
||||
const senderId = mEvent.getSender();
|
||||
|
||||
const myPowerlevel = room.getMember(mx.getUserId())?.powerLevel;
|
||||
|
@ -463,7 +471,7 @@ const MessageOptions = React.memo(({
|
|||
<div className="message__options">
|
||||
{canSendReaction && (
|
||||
<IconButton
|
||||
onClick={(e) => pickEmoji(e, roomId, eventId, roomTimeline)}
|
||||
onClick={(e) => pickEmoji(e, roomId, mEvent.getId(), roomTimeline)}
|
||||
src={EmojiAddIC}
|
||||
size="extra-small"
|
||||
tooltip="Add reaction"
|
||||
|
@ -501,7 +509,7 @@ const MessageOptions = React.memo(({
|
|||
iconSrc={BinIC}
|
||||
onClick={() => {
|
||||
if (window.confirm('Are you sure you want to delete this event')) {
|
||||
redactEvent(roomId, eventId);
|
||||
redactEvent(roomId, mEvent.getId());
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
@ -631,7 +639,7 @@ function Message({
|
|||
setIsEditing(true);
|
||||
}, []);
|
||||
const reply = useCallback(() => {
|
||||
replyTo(senderId, eventId, body);
|
||||
replyTo(senderId, mEvent.getId(), body);
|
||||
}, [body]);
|
||||
|
||||
if (body === undefined) return null;
|
||||
|
|
Loading…
Reference in a new issue