You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-11-04 11:51:45 +03:00 
			
		
		
		
	Fix issues with edited events not affecting threads (#8125)
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							3b523677fd
						
					
				
				
					commit
					f86cc74afc
				
			@@ -16,7 +16,7 @@ limitations under the License.
 | 
			
		||||
 | 
			
		||||
import React, { useContext } from "react";
 | 
			
		||||
import { Thread, ThreadEvent } from "matrix-js-sdk/src/models/thread";
 | 
			
		||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
 | 
			
		||||
import { MatrixEvent, MatrixEventEvent } from "matrix-js-sdk/src/models/event";
 | 
			
		||||
 | 
			
		||||
import { _t } from "../../../languageHandler";
 | 
			
		||||
import { CardContext } from "../right_panel/BaseCard";
 | 
			
		||||
@@ -74,12 +74,20 @@ interface IPreviewProps {
 | 
			
		||||
 | 
			
		||||
export const ThreadMessagePreview = ({ thread, showDisplayname = false }: IPreviewProps) => {
 | 
			
		||||
    const cli = useContext(MatrixClientContext);
 | 
			
		||||
 | 
			
		||||
    const lastReply = useTypedEventEmitterState(thread, ThreadEvent.Update, () => thread.replyToEvent);
 | 
			
		||||
    // track the replacing event id as a means to regenerate the thread message preview
 | 
			
		||||
    const replacingEventId = useTypedEventEmitterState(
 | 
			
		||||
        lastReply,
 | 
			
		||||
        MatrixEventEvent.Replaced,
 | 
			
		||||
        () => lastReply?.replacingEventId(),
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    const preview = useAsyncMemo(async () => {
 | 
			
		||||
        if (!lastReply) return;
 | 
			
		||||
        await cli.decryptEventIfNeeded(lastReply);
 | 
			
		||||
        return MessagePreviewStore.instance.generatePreviewForEvent(lastReply);
 | 
			
		||||
    }, [lastReply]);
 | 
			
		||||
    }, [lastReply, replacingEventId]);
 | 
			
		||||
    if (!preview) return null;
 | 
			
		||||
 | 
			
		||||
    const sender = thread.roomState.getSentinelMember(lastReply.getSender());
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user