Skip to content

Commit

Permalink
fix: showing wrong chat ("Reply Privately" quote)
Browse files Browse the repository at this point in the history
1. "Reply Privately" to a message
2. Click on the quote. This will open the original chat.
3. Click the "jump down" button.

This will load the messages from the private chat,
but still show the original group chat in the chat header.

This depends on deltachat/deltachat-core-rust#6453.
  • Loading branch information
WofWca committed Jan 19, 2025
1 parent 134079f commit 6282970
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- fix cancelation of account deletion when canceling clicking outside of the dialog
- fix unread counter on "jump to bottom" button showing incorrect count (taking the count from other chats) #4500
- fix clicking on message search result or "reply privately" quote not jumping to the message on first click #4510
- fix messages from wrong chat being shown after clicking on "jump down" button after revealing a message from a "Reply Privately" quote #4511

<a id="1_51_0"></a>

Expand Down
25 changes: 22 additions & 3 deletions packages/frontend/src/components/message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ export default function Message(props: {
<Quote
quote={message.quote}
msgParentId={message.id}
msgParentChatId={message.chatId}
// FYI the quote is not always interactive,
// e.g. when `quote.kind === 'JustText'`.
tabIndex={tabindexForInteractiveContents}
Expand Down Expand Up @@ -884,12 +885,24 @@ export default function Message(props: {
export const Quote = ({
quote,
msgParentId,
msgParentChatId,
tabIndex,
}: {
quote: T.MessageQuote
msgParentId?: number
tabIndex: -1 | 0
}) => {
} & (
| {
msgParentId: number
/**
* Must be provided if `msgParentId` is provided.
*/
msgParentChatId: number
}
| {
msgParentId?: undefined
msgParentChatId?: undefined
}
)) => {
const tx = useTranslationFunction()
const accountId = selectedAccountId()
const { jumpToMessage } = useMessage()
Expand All @@ -910,7 +923,13 @@ export const Quote = ({
msgId: quote.messageId,
msgChatId: undefined,
highlight: true,
msgParentId,
msgParentId:
// When the quote is from a different chat, let's not add it
// to the "jump down" stack, because otherwise
// if the user pops the stack by clicking the "jump down" button,
// we'll erroneously show messages from the previous chat
// without actually switching the chat
quote.chatId === msgParentChatId ? msgParentId : undefined,
// Often times the quoted message is already in view,
// so let's not scroll at all if so.
scrollIntoViewArg: { block: 'nearest' },
Expand Down
6 changes: 6 additions & 0 deletions packages/frontend/src/stores/messagelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,12 @@ class MessageListStore extends Store<MessageListState> {
* The latter (showing the message from a different chat), however,
* should not be used, because, as of 2025-01-19, we re-create
* `MessageListStore` when `chatId` or `accountId` changes.
* Another consequence of this is that when passing `addMessageIdToStack`,
* the message with the specified ID must belong to the chat with ID
* `MessageListStore.chatId`.
* For example, this must be checked for message quotes,
* because they might belong to a different chat due to the
* "Reply privately" feature.
*
* @param msgId - when `undefined`, pop the jump stack, or,
* if the stack is empty, jump to last message.
Expand Down

0 comments on commit 6282970

Please sign in to comment.