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)
Sat, Dec 21, 3:31 PM
Unknown Object (File)
Sat, Dec 21, 3:31 PM
Unknown Object (File)
Sat, Dec 21, 3:31 PM
Unknown Object (File)
Sat, Dec 21, 3:31 PM
Unknown Object (File)
Sat, Dec 21, 3:31 PM
Unknown Object (File)
Tue, Dec 3, 10:30 PM
Unknown Object (File)
Wed, Nov 27, 5:40 AM
Unknown Object (File)
Nov 23 2024, 1:00 PM
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
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul requested review of this revision.May 29 2024, 11:35 PM
ashoat added inline comments.
lib/shared/thread-utils.js
1016

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

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.