Fixes the ANR in #840, reported as "parsing emoji reactions" hanging after a
first sync. Three costs compounded, all inside a single Realm transaction:
- The bulk reparse cleared isEmojiReaction by walking every message in the
database and writing the field whether or not it was set. Query the flagged
messages instead, which on a typical history is a handful rather than tens of
thousands.
- findTargetMessage loaded every message in the thread and ran a regex over each
one, and it runs once per reaction. That product is quadratic across an
imported history. Bound it: a reaction can only target a message that already
existed, so filter by date, and cap the scan at the 200 most recent
candidates. A reaction refers to something the sender can still see, so a
target further back is not plausible.
- An untruncated quote, the common case, now matches natively in Realm on the
body column instead of materialising each candidate's text through getText(),
which walks MMS parts. MMS still falls through to the scan, since its text
lives in parts rather than body.
The date filter allows a minute of slack, because clock differences between two
devices can timestamp a reaction fractionally before the message it targets.
Also fixes the progress bar, which counted only messages that turned out to be
reactions while max counted every message examined. Progress could therefore
never reach max, so the bar never completed and the final callback never fired.
reactionDate is optional on the interface so existing callers keep compiling;
all three in-tree callers now pass it.
Android's normalizing function stripped out characters too aggressively leading to false matches between different numbers. This commit introduces a faster normalizing function that includes characters.
- Adds a new class of features for message management.
- Adds a manual option to find and delete duplicate messages
- Adds a setting to automatically delete duplicates during sync
- Adds a sha256 hashing function
Co-authored-by: octoshrimpy <octoshrimpy@users.noreply.github.com>
In some cases, (mainly on HyperOS and variants) content provider will return null if an empty conversation is created. This was breaking the compose activity as it expects some object other than null.
This commit changes the behavior to provide a new conversation object if createConversationFromCp ever returns null.
Some emoji reactions will appear as "Liked 'message...'" with the message cut off. This change uses a regex to match all ellipsis at the end of messages to any other message with the same content.