Page MenuHomePhabricator

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

Authored by atul on May 29 2024, 11:19 PM.
Tags
None
Referenced Files
F3154453: D12245.id40782.diff
Tue, Nov 5, 8:37 AM
Unknown Object (File)
Thu, Oct 10, 11:22 PM
Unknown Object (File)
Thu, Oct 10, 11:22 PM
Unknown Object (File)
Thu, Oct 10, 11:22 PM
Unknown Object (File)
Thu, Oct 10, 11:21 PM
Unknown Object (File)
Thu, Oct 10, 11:21 PM
Unknown Object (File)
Sep 28 2024, 3:22 AM
Unknown Object (File)
Sep 18 2024, 5:38 AM
Subscribers
None

Details

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

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

atul requested review of this revision.May 29 2024, 11:35 PM
ashoat added inline comments.
lib/shared/thread-utils.js
1016 ↗(On Diff #40772)

Rather than call values twice, I'd declare:

const permissionsDisabledByBlockArray = values(
  threadPermissionsDisabledByBlock,
);
This revision is now accepted and ready to land.May 30 2024, 6:41 AM
atul added inline comments.
lib/shared/thread-utils.js
1016 ↗(On Diff #40772)

Makes sense, will make that change.

atul marked an inline comment as done.

rebase and land

This revision was landed with ongoing or failed builds.May 30 2024, 11:02 AM
This revision was automatically updated to reflect the committed changes.