Page MenuHomePhabricator

[lib, native] [move] [ENG-991] replace canPromote thread logic to lib hook
ClosedPublic

Authored by benschac on Apr 21 2022, 8:21 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 28, 2:42 AM
Unknown Object (File)
Fri, Oct 25, 9:07 PM
Unknown Object (File)
Fri, Oct 25, 9:07 PM
Unknown Object (File)
Fri, Oct 25, 9:07 PM
Unknown Object (File)
Fri, Oct 25, 9:07 PM
Unknown Object (File)
Fri, Oct 25, 9:07 PM
Unknown Object (File)
Fri, Oct 25, 9:07 PM
Unknown Object (File)
Fri, Oct 25, 9:07 PM

Details

Summary

move can promote logic to promote thread hook for reuse in web project

Screen Recording 2022-04-21 at 11.22.55 AM.gif (810×353 px, 3 MB)

Image 2022-04-21 at 11.25.13 AM.jpg (846×710 px, 67 KB)

Test Plan

logic should be exactly the same as before, no new functionality. Just moving showing promote thread logic to the hook in lib.

Diff Detail

Repository
rCOMM Comm
Branch
promote-side-bar
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

benschac edited the test plan for this revision. (Show Details)
benschac edited the summary of this revision. (Show Details)
benschac retitled this revision from [lib, native] move,replace canPromote thread logic to lib hook to [lib, native] [move] [ENG-991] replace canPromote thread logic to lib hook.
lib/hooks/promote-sidebar.react.js
30 ↗(On Diff #11728)

I think this variable could be named better. What does it represent? If it's the parentThreadID in all cases, maybe we can name it that, and we could just always use it instead of ever checking threadInfo.parentThreadID

lib/hooks/promote-sidebar.react.js
30 ↗(On Diff #11728)

agreed, that makes sense.

Whoopsy! didn't implement the entire change.

I looked at this again, maybe for a bit too long and I'm having trouble figuring out exactly what you mean by @ashoat:

maybe we can name it that, and we could just always use it instead of ever checking threadInfo.parentThreadID

From what I understand about the feature, I think all we'd ever want is the threadInfo.parentID because a sidebar will always have a parentThread to be promoted from. I'm honestly not sure why this check was here in the first place.

If you have a minute today could we chat about it IRL.

lib/hooks/promote-sidebar.react.js
30 ↗(On Diff #11728)

Putting this back as needs review to get it back into @ashoat's queue to make sure he'll see my comment.

ashoat requested changes to this revision.Apr 27 2022, 2:27 PM
ashoat added inline comments.
lib/hooks/promote-sidebar.react.js
30 ↗(On Diff #11807)

I think all we'd ever want is the threadInfo.parentID because a sidebar will always have a parentThread to be promoted from. I'm honestly not sure why this check was here in the first place.

Assuming you mean threadInfo.parentThreadID... it seems like you're saying we don't need this parameter here, since we can get it from threadInfo.parentThreadID? In that case, let's simplify

40 ↗(On Diff #11807)

My feedback from the last review cycle is basically that I don't think we should have two distinct places we are getting parentThreadID from.

If there is some reason we can't trust threadInfo.parentThreadID, then I think this line should be handled by whoever calls usePromoteSidebar. That way, the third parameter to usePromoteSidebar will always be valid, and we never need to check threadInfo.parentThreadID. We could simplify lift this line to the caller and that would address my feedback

(That said, see my comment above – if we can trust threadInfo.parentThreadID, it seems cleaner to remove the third parameter here and just use that)

This revision now requires changes to proceed.Apr 27 2022, 2:27 PM

remove route / parent thread param

I need to test the functionality a bit before passing this over for review.

lib/hooks/promote-sidebar.react.js
30 ↗(On Diff #11807)

yes, that's the assumption! Awesome, thanks.

Tested promote thread functionality on both iOS and web and it's working as expected.

lib/hooks/promote-sidebar.react.js
40 ↗(On Diff #12036)

This is a copy/pasta from: https://github.com/CommE2E/comm/blob/master/native/chat/settings/thread-settings.react.js#L1119

It's not that obvious from the diff because we still need it in thread-settings.react / I didn't remove it in that file.

ashoat requested changes to this revision.Apr 28 2022, 11:43 AM
ashoat added inline comments.
lib/hooks/promote-sidebar.react.js
36 ↗(On Diff #12036)

What's the reason for this added newline?

39 ↗(On Diff #12036)

Can we git rid of ?? false? It's best for variables to have clean types, eg. ?string rather than ?string | boolean

39 ↗(On Diff #12036)

I think it's better to use the consistent name parentThreadID that we use everywhere in the codebase

39 ↗(On Diff #12036)

Can you remind me why you were passing this in as a third parameter? Are you 100% sure we can always trust threadInfo.parentThreadID?

39 ↗(On Diff #12036)

In what scenario will threadInfo be falsey? It's typed as ThreadInfo, so I don't understand why you need the question mark in threadInfo?.parentThreadID

This revision now requires changes to proceed.Apr 28 2022, 11:43 AM

diff review

lib/hooks/promote-sidebar.react.js
36 ↗(On Diff #12114)

going to get rid of this one too.

39 ↗(On Diff #12036)

yeah, makes sense.

39 ↗(On Diff #12036)

I'd say I'm about 90%. Here are the following steps I took to confirm that we can trust threadInfo.parentThreadID

ashoat requested changes to this revision.Apr 30 2022, 4:14 PM

Sending to your queue so we can discuss offline (see inline)

lib/hooks/promote-sidebar.react.js
38 ↗(On Diff #12116)

Hmm... RE trusting parentThreadID, the only reason I suspect we might have for not trusting parentThreadID is if it was a pending thread. Can you check with me in person / schedule some time on my Calendly so we can look into this together? I also want to explain the concept of a pending thread to you a bit

This revision now requires changes to proceed.Apr 30 2022, 4:14 PM
This revision is now accepted and ready to land.May 3 2022, 2:45 PM