HomePhabricator
Diffusion Comm 4a5089d43513

[native] Modify `messageStoreMessagesBlockListTransform` to ensure messageStore…

Description

[native] Modify messageStoreMessagesBlockListTransform to ensure messageStore migration completes successfully

Summary:
Context: https://linear.app/comm/issue/ENG-2377/upgrading-from-build-131-public-release-to-build-=154-leads-to-empty

Basically in D5545 we made sure to set messageStore.messages to {} so we wouldn't run into issues with messageStore.messages being undefined.

It was a reasonable assumption to make that messageStore.messages would always be undefined coming into this transform since we no longer persist messages via redux-persist.

However, there is one situation where we expect messageStore.messages to exist AND where we NEED the contents... and that's in migration 31 where we switch over from persisting messages via redux-persist to storing them in the SQLite messages table. That migration depends on the contents of messageStore.messages to construct the "message ops" that--when processed--populate the SQLite messages table for the first time.

Because messageStoreMessagesBlocklistTransform modifies the messageStore before migrations are run, we were inadvertently clearing messageStore.messages for older clients before migration 31 completed... leaving them with an empty messageStore.messages even after a "successful" SET_MESSAGE_STORE_MESSAGES. This diff handles that situation by setting messageStore.messages to {} only if undefined (or falsey) via nullish coalescing.

Test Plan:

  1. Install build 131 on my iPhone via App Store
  2. Make a release build that includes this change and deploy to my phone
  3. Make sure that messages continue to appear in the app as expected

Reviewers: ashoat, tomek, marcin

Reviewed By: ashoat

Differential Revision: https://phab.comm.dev/D5762