Page MenuHomePhabricator

[native] correctly measure multimedia messages that have an inline engagement
ClosedPublic

Authored by ginsu on Jul 25 2023, 10:52 PM.
Tags
None
Referenced Files
F3370277: D8634.diff
Tue, Nov 26, 1:44 AM
Unknown Object (File)
Sat, Nov 23, 6:57 PM
Unknown Object (File)
Sat, Nov 23, 6:57 PM
Unknown Object (File)
Sat, Nov 23, 4:24 PM
Unknown Object (File)
Fri, Nov 15, 11:39 PM
Unknown Object (File)
Fri, Nov 8, 2:35 PM
Unknown Object (File)
Fri, Nov 1, 2:19 PM
Unknown Object (File)
Fri, Nov 1, 2:18 PM
Subscribers

Details

Summary

This diff handles correctly measuring multimedia messages. Multimedia needed to be handled a little bit differently since we use the image height and the composed message width to determine the contentHeight and we actually don't perform a measurement on multimedia messages.

This means that for multimedia messages we only need to measure the inline engagement and then in multimediaMessageItemHeight we can add the contentHeight w/ the height of the inline engagement we get from the NodeHeightMeasurer.

Depends on D8632

Test Plan

I tested modifying the height of the inline engagement for multimedia messages, and when I did this I no longer got incorrect height measurement logs from the console. I performed the same tests outlined in the test plan D8632 (except edit label test, but you can't edit multimedia message)

Before:

Screenshot 2023-07-26 at 1.46.32 AM.png (1×3 px, 1 MB)

After:

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

native/chat/chat-item-height-measurer.react.js
113–116 ↗(On Diff #29039)

We can move this invariant earlier in the function since height will be the height of the inline engagement for multimedia messages

native/chat/inner-multimedia-message.react.js
35 ↗(On Diff #29039)

I explained why I added the View here:

https://phab.comm.dev/D8610#inline-55215

native/chat/multimedia-message-utils.js
119 ↗(On Diff #29039)

When there is no inline engagement, inlineEngagementHeight will just be 0

native/types/chat-types.js
65 ↗(On Diff #29039)

When there is no inline engagement, inlineEngagementHeight will just be 0. We could also make this optional if people prefer, but I thought it made more sense just to make this field required

tomek requested changes to this revision.Jul 26 2023, 3:43 AM
tomek added inline comments.
native/chat/chat-item-height-measurer.react.js
146 ↗(On Diff #29039)

This is inconsistent with the value returned for e.g. TEXT message. Why do we return inlineEngagementHeight for one message type and don't for the other? Is there a way to make this less missleading?

native/chat/inner-multimedia-message.react.js
30 ↗(On Diff #29039)

This name might be confusing, as this isn't the whole multimedia message. Maybe just dummyNodeForInlineEngagementHeightMeasurement would be ok?

native/types/chat-types.js
65 ↗(On Diff #29039)

Both approaches are ok to me (maybe optional is slightly better as it is more explicit that there's no inline engagement), but I'm wondering why e.g. isPinned is optional in that case

This revision now requires changes to proceed.Jul 26 2023, 3:43 AM
ginsu added inline comments.
native/chat/chat-item-height-measurer.react.js
146 ↗(On Diff #29039)

Here is my explanation for why I added inlineEngagementHeight to ChatMultimediaMessageInfoItem:

Multimedia messages needed to be handled a little bit differently since we use the image height and the composed message width to determine the contentHeight and we actually don't perform a measurement on multimedia messages. (ChatMultimediaMessageInfoItem also uses MultimediaContentSizes and the other message types do not https://github.com/CommE2E/comm/blob/master/native/types/chat-types.js#L51C1-L52C1)

This means that for multimedia messages we only need to measure the inline engagement and then in multimediaMessageItemHeight we can add the contentHeight w/ the height of the inline engagement we get from the NodeHeightMeasurer.

Hope this helps, but please let me know if I need to elaborate more, or consider a different solution for multimedia messages.

native/chat/inner-multimedia-message.react.js
30 ↗(On Diff #29039)

This makes sense, I will then rename this function and move it into native/chat/inline-engagement.react.js

native/types/chat-types.js
65 ↗(On Diff #29039)

but I'm wondering why e.g. isPinned is optional in that case

@rohan do you have a quick answer for this by any chance?

native/types/chat-types.js
65 ↗(On Diff #29039)

If I remember right, it's because we don't allow robotext messages to be pinned.

So in chat-selectors.js, we only add the isPinned property for the composable message types (text and multimedia).

Because of this, I'd run into flow issues by expecting isPinned to exist all the time for all messages, specifically in the chat-item-height-measurer.react.js file if I removed the optional parameter.

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ chat/chat-item-height-measurer.react.js:178:29

Cannot create NodeHeightMeasurer element because boolean [1] is incompatible with void (due to access of non-existent
property isPinned) [2] in property isPinned of array element of the first parameter of property allHeightsMeasured.
[incompatible-type]

     chat/chat-item-height-measurer.react.js
 [2] 137│           isPinned: item.isPinned,
        :
     175│         itemToMeasureKey={heightMeasurerKey}
     176│         itemToDummy={heightMeasurerDummy}
     177│         mergeItemWithHeight={heightMeasurerMergeItem}
     178│         allHeightsMeasured={measurement.onMessagesMeasured}
     179│         inputState={inputState}
     180│         composedMessageMaxWidth={composedMessageMaxWidth}
     181│         initialMeasuredHeights={measurement.initialMeasuredHeights}

     types/chat-types.js
 [1]  42│   +isPinned: boolean,

The workaround to this was to include isPinned for robotext messages as well, but that didn't seem to make sense since it's not possible. I believe hasBeenEdited does the same thing as I remember checking for why that was optional.

Let me know if that doesn't clear things up / I can answer any more questions!

native/types/chat-types.js
65 ↗(On Diff #29039)

Ah that makes sense, thank you for your detailed explanation!

native/chat/chat-item-height-measurer.react.js
154 ↗(On Diff #29156)

Here is my explanation for why I added inlineEngagementHeight to ChatMultimediaMessageInfoItem:

Multimedia messages needed to be handled a little bit differently since we use the image height and the composed message width to determine the contentHeight and we actually don't perform a measurement on multimedia messages. (ChatMultimediaMessageInfoItem also uses MultimediaContentSizes and the other message types do not https://github.com/CommE2E/comm/blob/master/native/types/chat-types.js#L51C1-L52C1)

This means that for multimedia messages we only need to measure the inline engagement and then in multimediaMessageItemHeight we can add the contentHeight w/ the height of the inline engagement we get from the NodeHeightMeasurer.

Hope this helps, but please let me know if I need to elaborate more, or consider a different solution for multimedia messages.

native/chat/inline-engagement.react.js
41 ↗(On Diff #29156)

I explained why I added the View here:

https://phab.comm.dev/D8610#inline-55215

tomek added inline comments.
native/chat/chat-item-height-measurer.react.js
154 ↗(On Diff #29156)

Thanks! I understand why we need this but was concerned about inconsistency: it might be surprising to a dev why this value equals zero for TEXT messages that have inline engagement. One possible improvement might be to compute this value for all the message types (I prefer that). Another solution might be to have this nullable for non-multimedia message types. But at least, we should have some code comments explaining what's going on.

This revision is now accepted and ready to land.Jul 28 2023, 1:34 AM

add some comments + rebase before landing

This revision was landed with ongoing or failed builds.Jul 31 2023, 1:19 PM
This revision was automatically updated to reflect the committed changes.