-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lib] Introduce RawThickThreadInfo type
Summary: This diff splits `RawThreadInfo` into `RawThinThreadInfo` (basically the old type) and `RawThickThreadInfo`, which will be used for E2E-encrypted DMs. The latter type includes `ThreadSubscription` for each member. I tried to break this diff down but it was tough due to Flow issues. This diff doesn't update `ThreadInfo`. That type is used generally in frontend code, and I'm not sure we'll need the new `ThreadSubscription`. This diff also doesn't do anything to make sure we handle `RawThickThreadInfo` correctly when we encounter it. That will be handled in later tasks. It's okay to commit this type change now as we aren't actually introducing `RawThickThreadInfo` to any stores. On the Flow side here, I had to add a `thick: true` attribute. I initially tried to differentiate the two types through the `type` field, which should let us represent `RawThreadInfo` was a union of two disjoint types (`RawThinThreadInfo` and `RawThickThreadInfo`). But I wasn't able to get Flow to narrow the types when I checked the `type` field. Here's what I tried: - Enumerating all of the possible values of `type` at every location, for both the thick and thin conditions. This worked but was way too verbose - Considered using [type guards](https://flow.org/en/docs/types/type-guards/), but our setup [doesn't support](https://flow.org/en/docs/types/type-guards/#toc-adoption) them yet. More details in [this blog](https://medium.com/flow-type/announcing-user-defined-type-guards-in-flow-b979bb2e78cf) - Considered using an older version of type guards: assert functions that use `%checks`. However this wasn't able to narrow a `threadInfo` by checking `threadInfo.type` for some reason - Considered using assert functions that just have `invariant`s and `any`s instead of `%checks`. This resulted in four functions: `assertThinRawThreadInfo`, `assertThickRawThreadInfo`, `assertLegacyThinRawThreadInfo`, `assertLegacyThickRawThreadInfo`. A pair of these would be combined with a `threadTypeIsThick` check. Ultimately decided it was too verbose - Referenced [this GitHub issue](facebook/flow#6516 (comment)) where something similar is discussed Depends on D12494 Test Plan: Flow Reviewers: kamil, marcin Reviewed By: marcin Subscribers: tomek Differential Revision: https://phab.comm.dev/D12495
- Loading branch information
Showing
9 changed files
with
419 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.