HomePhabricator
Diffusion Comm 121cf3dce618

[keyserver/lib/native] Store the number of pinned messages in ThreadInfo

Description

[keyserver/lib/native] Store the number of pinned messages in ThreadInfo

Summary:
We want to include pinnedCount inside ThreadInfos in order to avoid having to dynamically fetch this number each time a thread is opened. This diff handles this in two ways:

  1. We always want to include pinnedCount in ServerThreadInfo - then, based on the code version on native, we'd want to conditionally include it into the downstream ThreadInfo types (where we construct, for example, RawThreadInfo from ServerThreadInfo).
  1. Introduce a redux persist migration to target newly updated clients. Each step in the migration is commented to indicate its purpose. One case that is already handled but important to note: if an old client and a new client are in a thread together (pre and post message pinning versions), when we update the old client, we need to make sure we don't initialize pinnedCount to 0, but instead derive the pinnedCount based on the thread and existence of TOGGLE_PIN messages because there may be message pins in the thread.

Linear: https://linear.app/comm/issue/ENG-3396/store-the-number-of-pinned-messages-in-threadinfo

Depends on D7202

Test Plan:

  1. Install native off master
  2. git checkout pinned_messages
  3. Go on the web client and pin several messages
  4. Add the redux-persist migration
  5. Open the native app
  6. Run yarn redux-devtools and confirm that threadStore has updated pinnedCount values.

Screenshot 2023-03-27 at 7.43.22 PM.png (806×1 px, 136 KB)

  1. Check the redux devtools on the web client and confirm that threadStore has the updated pinnedCount values.

Screenshot 2023-03-27 at 8.01.07 PM.png (798×1 px, 139 KB)

  1. Check that ThreadInfo contains pinnedCount:

Screenshot 2023-03-27 at 8.01.43 PM.png (600×1 px, 135 KB)

Reviewers: atul, ginsu, tomek, ashoat

Reviewed By: atul

Subscribers: ashoat

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