Page MenuHomePhabricator

[native] introduce useReactionSelectionPopoverPosition hook
ClosedPublic

Authored by ginsu on Jan 29 2023, 8:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 11, 10:36 AM
Unknown Object (File)
Thu, Dec 5, 12:35 PM
Unknown Object (File)
Thu, Dec 5, 11:44 AM
Unknown Object (File)
Nov 1 2024, 11:52 AM
Unknown Object (File)
Nov 1 2024, 11:52 AM
Unknown Object (File)
Nov 1 2024, 11:50 AM
Unknown Object (File)
Nov 1 2024, 11:50 AM
Unknown Object (File)
Nov 1 2024, 11:49 AM
Subscribers

Details

Summary

introduce useReactionSelectionPopoverPosition hook. This hook will be used to help position the reaction selection popover based off the size/position of the message and chat window


Depends on D6447
Linear Task: ENG-2779

Test Plan

flow and this will be further tested in a subsequent diff

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ginsu requested review of this revision.Jan 29 2023, 8:41 PM
tomek requested changes to this revision.Jan 30 2023, 5:03 AM

We're copying a lot of complicated logic. Can we reuse it in a different way?

native/navigation/tooltip.react.js
444–445 ↗(On Diff #21547)

Why we're using this strange syntax?

This revision now requires changes to proceed.Jan 30 2023, 5:03 AM

put reactionSelectionPopoverContainerStyle logic into a hook called useReactionSelectionPopoverPosition

remove reactionSelectionPopoverContainerStyle from tooltip

ginsu retitled this revision from [native] introduce get reactionSelectionPopoverContainerStyle to [native] introduce useReactionSelectionPopoverPosition hook.Jan 31 2023, 12:36 PM
ginsu edited the summary of this revision. (Show Details)

An approach looks better, but we're duplicating a lot of logic. We should reuse it by e.g. introducing functions with common parts. Accepting, to not block the goal, but please improve this later.

native/chat/reaction-message-utils.js
132–146 ↗(On Diff #21709)

Why do we use such complicated syntax? Was it copied from somewhere? The margin calculation can be replaced by just

const calculatedMargin = margin ?? 16;

But we can simplify it one step further by using a default value.

155 ↗(On Diff #21709)

Is it really beneficial to introduce this variable?

This revision is now accepted and ready to land.Feb 1 2023, 2:12 AM

address tomek's comments

An approach looks better, but we're duplicating a lot of logic. We should reuse it by e.g. introducing functions with common parts. Accepting, to not block the goal, but please improve this later.

https://linear.app/comm/issue/ENG-2910/refactor-tooltip-and-reaction-selection-popover-positioningstyling

native/chat/reaction-message-utils.js
132–146 ↗(On Diff #21709)

Unfortunately, flow can't pick up default values, so went with the first suggestion.