Page MenuHomePhabricator

[lib] Populate messageStore.threads from threadInfos before setMessageStoreMessages
ClosedPublic

Authored by ashoat on Nov 18 2022, 6:07 AM.
Tags
None
Referenced Files
F3502686: D5669.diff
Fri, Dec 20, 4:48 AM
Unknown Object (File)
Fri, Dec 6, 8:21 PM
Unknown Object (File)
Wed, Dec 4, 9:09 AM
Unknown Object (File)
Tue, Nov 26, 5:35 AM
Unknown Object (File)
Sun, Nov 24, 11:53 AM
Unknown Object (File)
Oct 29 2024, 12:48 PM
Unknown Object (File)
Oct 15 2024, 10:36 PM
Unknown Object (File)
Oct 1 2024, 6:08 AM
Subscribers
None

Details

Summary

See ENG-2275, specifically this comment.

We were seeing an exception being thrown because messageStore.threads was missing a thread that was in SQLite. Calling updateMessageStoreWithLatestThreadInfos before this exception might help address the issue by making sure messageStore.threads has an entry for every threadInfo that we have in SQLite.

The exception may still be thrown after this diff, but it would require SQLite's threads table to be inconsistent with its messages table, rather than just redux-persist's messageStore.threads being inconsistent with SQLite's messages table.

Test Plan

Confirm that issue in ENG-2275 no longer repros

Diff Detail

Repository
rCOMM Comm
Branch
ashoat/androidNotifIssue
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

lib/reducers/message-reducer.js
189–193

These should never have been typed as $ReadOnly. The arrays are constructed anew in the function, so it's okay for the caller to do whatever they want with them

571–575

Same as above

1364

I removed this early exit since processMessageStoreOperations is a clean no-op when messageStoreOperations is empty anyways

1381–1384

This is the same as just returning processedMessageStore directly

Tested this and it works to prevent crash, but the messages are all still lost since when the SAVE_MESSAGES action gets processed it ends up triggering updateMessageStoreWithLatestThreadInfos with an empty ThreadStore and thus generating a remove_messages_for_threads op to delete messages from SQLite. D5667 is still needed to prevent the SAVE_MESSAGES action from firing, but this change is still a good change.

This revision is now accepted and ready to land.Nov 21 2022, 1:38 PM