HomePhabricator
Diffusion Comm 2d73eae9c45a

[lib] Pull `threadPermissionsDisabledByBlock` out from `threadPermissions`

Description

[lib] Pull threadPermissionsDisabledByBlock out from threadPermissions

Summary:
We want to update threadHasPermission so the permission argument takes something like ThreadPermissionNotDisabledByBlock.

We currently have threadPermissions and permissionsDisabledByBlockArray, and we effectively want ThreadPermissionNotDisabledByBlock to be union of values in threadPermissions with values of permissionsDisabledByBlockArray subtracted. I spent a lot of time trying to figure this out with flow, but couldn't find a simple way to type this. (I believe the Exclude utility available in flow >= 0.209 could help: https://flow.org/en/docs/types/utilities/#toc-exclude)

The best approach seems to be to "build" threadPermissions by spreading in threadPermissionsDisabledByBlock and something like threadPermissionsNotAffectedByBlock so we can use $Values on each individually as well as the composite type.

This diff just handles pulling out threadPermissionsDisabledByBlock and replacing the existing permissionsDisabledByBlockArray. The next diff will pull out threadPermissionsNotAffectedByBlock.


Depends on D12158

Test Plan: flow + ESLint

Reviewers: ashoat, ginsu, tomek, varun

Reviewed By: ashoat

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

Details