Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix pinned message edits does not reflect in pinned messages #2107

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions src/app/features/room/room-pin-menu/RoomPinMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/destructuring-assignment */
import React, { forwardRef, MouseEventHandler, useCallback, useMemo, useRef } from 'react';
import { MatrixEvent, RelationType, Room } from 'matrix-js-sdk';
import { MatrixEvent, Room } from 'matrix-js-sdk';
import { RoomPinnedEventsEventContent } from 'matrix-js-sdk/lib/types';
import {
Avatar,
Expand Down Expand Up @@ -257,6 +257,7 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
msgType={event.getContent().msgtype ?? ''}
ts={event.getTs()}
getContent={getContent}
edited={!!event.replacingEvent}
mediaAutoLoad={mediaAutoLoad}
urlPreview={urlPreview}
htmlReactParserOptions={htmlReactParserOptions}
Expand Down Expand Up @@ -311,7 +312,7 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
displayName={displayName}
msgType={mEvent.getContent().msgtype ?? ''}
ts={mEvent.getTs()}
edited={!!editedEvent}
edited={!!editedEvent || !!mEvent.replacingEvent}
getContent={getContent}
mediaAutoLoad={mediaAutoLoad}
urlPreview={urlPreview}
Expand Down
8 changes: 7 additions & 1 deletion src/app/hooks/useRoomEvent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MatrixEvent, Room } from 'matrix-js-sdk';
import { IEvent, MatrixEvent, Room } from 'matrix-js-sdk';
import { useCallback, useMemo } from 'react';
import to from 'await-to-js';
import { CryptoBackend } from 'matrix-js-sdk/lib/common-crypto/CryptoBackend';
Expand All @@ -12,6 +12,12 @@ const useFetchEvent = (room: Room, eventId: string) => {
const evt = await mx.fetchRoomEvent(room.roomId, eventId);
const mEvent = new MatrixEvent(evt);

if (evt.unsigned?.['m.relations'] && evt.unsigned?.['m.relations']['m.replace']) {
const replaceEvt = evt.unsigned?.['m.relations']['m.replace'] as IEvent;
const replaceEvent = new MatrixEvent(replaceEvt);
mEvent.makeReplaced(replaceEvent);
}

if (mEvent.isEncrypted() && mx.getCrypto()) {
await to(mEvent.attemptDecryption(mx.getCrypto() as CryptoBackend));
}
Expand Down
Loading