Skip to content

fix: whatsapp archive lthash mismatch and UI history refresh#504

Open
asemarafa wants to merge 1 commit intod99kris:masterfrom
asemarafa:fix-whatsapp-archive-lthash
Open

fix: whatsapp archive lthash mismatch and UI history refresh#504
asemarafa wants to merge 1 commit intod99kris:masterfrom
asemarafa:fix-whatsapp-archive-lthash

Conversation

@asemarafa
Copy link
Copy Markdown
Contributor

This PR addresses the issue where WhatsApp chats fail to sync their archive/unarchive state properly when modified from another device (e.g.,
a phone) while nchat is offline or disconnected.

What this fixes:

  1. ErrMismatchingLTHash in whatsmeow: When the local app state hash does not match the server's hash, whatsmeow previously failed silently on
    ErrMismatchingLTHash. This patch catches the error and explicitly sends a BuildAppStateRecoveryRequest to heal the local state.

  2. UI History Refresh (uimodel.cpp): When a chat is unarchived, the application sends a request for new messages. However, prior message
    requests might have been silently dropped by the NewMessagesNotify handler when the chat was still considered archived locally. This
    clears any previously requested message IDs and calls UpdateHistory() to ensure the UI accurately reflects any messages that arrived while
    the chat was archived.

- Request app state recovery upon LTHash mismatch in whatsmeow.
- Clear requested message IDs and refresh UI history when a chat is unarchived in uimodel.
@d99kris d99kris self-assigned this Mar 28, 2026
@d99kris
Copy link
Copy Markdown
Owner

d99kris commented Mar 29, 2026

Hi @asemarafa - thanks for contributing again. 👍
Ideally I try to minimize code changes in third-party libs, like whatsmeow, but I will review the changes and see how we can proceed. Sometimes it's preferred to contribute them upstream instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants