From b336bc93e00874033cc020154fb3fc46780d8d50 Mon Sep 17 00:00:00 2001 From: WofWca Date: Wed, 12 Feb 2025 00:02:04 +0400 Subject: [PATCH] fix: "Show in Chat" in gallery not working The bug was likely introduced in https://github.com/deltachat/deltachat-desktop/pull/4554 (da4b9167513c76c5bc89e1302aedaf4cde020e40) or in one of the adjacent / related commmits. FYI the bug has only been released with 1.53.0. --- CHANGELOG.md | 1 + .../src/components/message/MessageList.tsx | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d07a1e44bd..d61d2784e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Changed ### Fixed +- "Show in Chat" in Gallery not working #4629 diff --git a/packages/frontend/src/components/message/MessageList.tsx b/packages/frontend/src/components/message/MessageList.tsx index 70f6509fb5..2c65738e6c 100644 --- a/packages/frontend/src/components/message/MessageList.tsx +++ b/packages/frontend/src/components/message/MessageList.tsx @@ -235,9 +235,20 @@ export default function MessageList({ accountId, chat, refComposer }: Props) { } } maybeJumpToMessageHack() - // TODO perf: to save memory, maybe set to `undefined` when unmounting, - // but be sure not to unset it if the new component render already set it. window.__internal_check_jump_to_message = maybeJumpToMessageHack + useEffect(() => { + // Unset this wneh unmounting, so that it's the next component instance + // that handles the `__internal_jump_to_message_asap` value. + // This is important e.g. for "Show in Chat" in the gallery. + // The gallery is displayed when the MessageList component + // is not displayed. + // + // TODO we probably need to ensure that the next component instance + // didn't already set it itself. + return () => { + window.__internal_check_jump_to_message = undefined + } + }, []) const pendingProgrammaticSmoothScrollTo = useRef(null) const pendingProgrammaticSmoothScrollTimeout = useRef(-1)