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)
Wed, Dec 25, 5:33 AM
Unknown Object (File)
Wed, Dec 25, 5:33 AM
Unknown Object (File)
Wed, Dec 25, 5:33 AM
Unknown Object (File)
Wed, Dec 25, 5:33 AM
Unknown Object (File)
Wed, Dec 25, 5:33 AM
Unknown Object (File)
Wed, Dec 25, 5:32 AM
Unknown Object (File)
Tue, Dec 24, 5:55 PM
Unknown Object (File)
Mon, Dec 16, 12:49 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
Branch
inka/actions
Lint
No Lint Coverage
Unit
No Test Coverage

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