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
Unknown Object (File)
Sat, Nov 23, 10:39 PM
Unknown Object (File)
Sat, Nov 23, 8:54 PM
Unknown Object (File)
Sat, Nov 23, 8:27 PM
Unknown Object (File)
Sat, Nov 23, 5:38 PM
Unknown Object (File)
Sat, Nov 23, 3:32 PM
Unknown Object (File)
Wed, Nov 20, 4:48 PM
Unknown Object (File)
Mon, Nov 11, 12:40 AM
Unknown Object (File)
Oct 27 2024, 10:19 PM
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