Page MenuHomePhabricator

[lib, native, web] move onChangeSearch to hook
ClosedPublic

Authored by benschac on May 16 2022, 8:07 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 6, 11:25 PM
Unknown Object (File)
Thu, Apr 4, 9:20 PM
Unknown Object (File)
Thu, Apr 4, 10:41 AM
Unknown Object (File)
Thu, Apr 4, 7:12 AM
Unknown Object (File)
Mon, Apr 1, 1:25 PM
Unknown Object (File)
Sun, Mar 31, 1:26 PM
Unknown Object (File)
Tue, Mar 26, 4:17 PM
Unknown Object (File)
Wed, Mar 20, 8:22 PM

Details

Summary

move onChangeSearch to lib/hooks/ from native and web.

Test Plan

Use the search sidebar feature in both native and web and confirm functionality still works as expected.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ashoat requested changes to this revision.May 16 2022, 1:18 PM
ashoat added inline comments.
lib/hooks/search-sidebars.js
64–69 ↗(On Diff #12745)

I don't like this, let's find a better way to figure this out. If you need more help on this please consult @atul

This revision now requires changes to proceed.May 16 2022, 1:18 PM
ashoat requested changes to this revision.May 17 2022, 12:42 PM

Please hit "Plan Changes" to remove this from your reviewers' queue after rebasing

This revision now requires changes to proceed.May 17 2022, 12:42 PM
benschac removed a reviewer: ashoat. benschac added 1 blocking reviewer(s): atul.May 19 2022, 12:52 PM

Took a stab at fixing the comment above. I removed @ashoat as a reviewer since he requested @atul confirm my change and made the blocking review @atul.

I removed @ashoat as a reviewer since he requested @atul confirm my change and made the blocking review @atul

Thank you, that's perfect!!

atul requested changes to this revision.May 20 2022, 8:24 AM

Looks close, left some thoughts/suggestions inline. Only thing I think needs to be addressed before accepting is changing onChangeSearchText return type from mixed -> void

lib/hooks/search-sidebars.js
23 ↗(On Diff #12971)

Shouldn't this be void instead of mixed? Let me know if I'm missing something

(fwiw arc patch'd, made change, and there were no issues with flow)

native/chat/sidebar-list-modal.react.js
38 ↗(On Diff #12971)

Thoughts on naming this something like onChangeSearchInputValue or onChangeSearchInputText or something?

Just to make it clear that this callback is "triggered" when the value of the Input component changes, and not when the value of the searchState text changes?

Don't feel strongly, up to you


As an aside, since this callback is about handling an input event "within" the component... would it make more sense to leave the onChangeSearchText callback inside the component? Even though there's some repetition, it might keep related things closer?

68–71 ↗(On Diff #12971)

Should we instead replace this with:

onChangeSearchText('');

?

Then we can avoid using setSearchState "directly" and make onChangeSearchState the "API" for dealing with searchState?


If we do this in web as well (in clearQuery), we could remove setSearchState from the object returned by useSearchSidebars?

web/modals/chat/sidebar-list-modal.react.js
64 ↗(On Diff #12971)

Should we instead replace this with:

onChangeSearchText('');

?

Then we can avoid using setSearchState "directly" and make onChangeSearchState the "API" for dealing with searchState?

This revision now requires changes to proceed.May 20 2022, 8:24 AM
lib/hooks/search-sidebars.js
23 ↗(On Diff #12971)

Returning mixed is common for a callback type... it's a way of saying "I don't care what your callback returns, it can return whatever... I'm just going to ignore it"

benschac added inline comments.
web/modals/chat/sidebar-list-modal.react.js
64 ↗(On Diff #12971)

Yeah, that makes sense. Could I do that in a following diff. In

address atul's comment change onChangeSearchText -> onChangeSearchInputText

atul added inline comments.
web/modals/chat/sidebar-list-modal.react.js
64 ↗(On Diff #12971)

Yeah sounds good, should prob make a linear task for it

This revision is now accepted and ready to land.May 25 2022, 10:26 AM
native/chat/sidebar-list-modal.react.js
38 ↗(On Diff #12971)

I just changed everything to onChangeSearchInputText I think that made the most sense.

68–71 ↗(On Diff #12971)

This gets changed a bit over in: https://phabricator.ashoat.com/D4060. This functionality gets handled in the https://github.com/CommE2E/comm/blob/master/web/modals/search-modal.react.js#L9 component.

native/chat/sidebar-list-modal.react.js
68–71 ↗(On Diff #12971)

talked to @atul IRL. This gets handled in https://phabricator.ashoat.com/D4060, and is okay.