Page MenuHomePhabricator

[lib][web][native] Refactor actions in message-actions.js
ClosedPublic

Authored by inka on Sep 20 2023, 2:23 AM.
Tags
None
Referenced Files
F2212896: D9240.diff
Mon, Jul 8, 9:52 AM
F2212523: D9240.id31312.diff
Mon, Jul 8, 7:27 AM
Unknown Object (File)
Thu, Jun 27, 7:32 AM
Unknown Object (File)
Wed, Jun 26, 8:54 PM
Unknown Object (File)
Sun, Jun 23, 10:50 AM
Unknown Object (File)
Sat, Jun 22, 9:31 PM
Unknown Object (File)
Fri, Jun 21, 12:35 PM
Unknown Object (File)
Fri, Jun 21, 9:40 AM
Subscribers

Details

Summary

issue: https://linear.app/comm/issue/ENG-4681/create-action-objects-for-all-actions
We want to start migrating our actions to using useKeyserverCall. We need to create an object for each action that will contain the ActionFunc and a config.
Additionally we agreed to wrap the call to useKeyserverCall into a separate hook for every action. For more info see comments under https://linear.app/comm/issue/ENG-4440/refactor-redux-fields-second-iteration-refactor-actions
For now those hooks are very simple, but in the future they will contain more logic

Test Plan

Tested that all of the refactored actions work. Ran yarn flow-all.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

inka requested review of this revision.Sep 20 2023, 2:41 AM
michal requested changes to this revision.Sep 26 2023, 3:15 AM

Requesting changes because I have a few smaller comments

lib/actions/message-actions.js
40 ↗(On Diff #31312)

Should probably be renamed everywhere

182–187 ↗(On Diff #31312)
541 ↗(On Diff #31312)

Shouldn't this be a specific endpoint?

lib/utils/keyserver-id-extractors.js
7–23 ↗(On Diff #31312)

Not sure if I'm a fan of this approach. Are we just going to be adding a new function whenever some action uses a different field name? I think I would prefer to have inline functions inside of the "config" objects and invariant inside of the extractKeyserverIDFromID function.

This revision now requires changes to proceed.Sep 26 2023, 3:15 AM

Address review + changes due to review for D9217

michal added inline comments.
lib/actions/message-actions.js
121–136 ↗(On Diff #31613)

Would something like this work? IMO it's simpler

lib/utils/action-utils.js
459 ↗(On Diff #31613)

Maybe something like groupThreadIDsPerKeyserver would be a better name?

This revision is now accepted and ready to land.Oct 4 2023, 7:00 AM
lib/utils/action-utils.js
459 ↗(On Diff #31613)

This function is used in almost all diffs, so to not spend a lot of time on in I will update it in one diff at the top of the stack