Page MenuHomePhabricator

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

Authored by atul on May 29 2024, 11:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 18, 10:18 PM
Unknown Object (File)
Sun, Nov 10, 8:05 PM
Unknown Object (File)
Sun, Nov 10, 6:09 PM
Unknown Object (File)
Sun, Nov 10, 4:22 PM
Unknown Object (File)
Sun, Nov 10, 9:35 AM
Unknown Object (File)
Sun, Nov 10, 8:23 AM
Unknown Object (File)
Tue, Nov 5, 1:28 PM
Unknown Object (File)
Tue, Nov 5, 8:37 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.