Page MenuHomePhabricator

[native] Extract from SidebarListModal code that can be reused for the subchannels modal
ClosedPublic

Authored by inka on Dec 21 2022, 7:10 AM.
Tags
None
Referenced Files
F3354879: D5971.id19950.diff
Sat, Nov 23, 1:35 PM
F3354864: D5971.id20373.diff
Sat, Nov 23, 1:30 PM
F3354857: D5971.id20315.diff
Sat, Nov 23, 1:27 PM
F3354844: D5971.id20148.diff
Sat, Nov 23, 1:24 PM
F3354087: D5971.diff
Sat, Nov 23, 11:41 AM
Unknown Object (File)
Wed, Nov 6, 3:35 PM
Unknown Object (File)
Mon, Nov 4, 8:30 AM
Unknown Object (File)
Mon, Nov 4, 8:30 AM
Subscribers

Details

Summary

Related Linear task: https://linear.app/comm/issue/ENG-2373/subchannels-view
The subchannels modal is supposed to be similar to SidebarListModal, so I extracted from it the code that can be reused.

Test Plan

Run ios simulator, see that sidebar modal works

Diff Detail

Repository
rCOMM Comm
Branch
inka/community_drawer
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

inka requested review of this revision.Dec 21 2022, 7:22 AM
native/chat/sidebar-list-modal.react.js
39–43

Since the onPressItem function is the same for the sidebars modal and the subchannels modal, but renderItem is not (because of the checks that need to be performed in the following lines), I decided to inject onPressItem to the renderItem function. So this is a function that takes onPressItem as an argument, and returns a renderItem function based on it.

native/chat/thread-list-modal.react.js
67–79

onPressItem uses state internal to the component, so it cannot be moved out of it.

kamil requested changes to this revision.Dec 22 2022, 6:31 AM
kamil added inline comments.
native/chat/thread-list-modal.react.js
37

why the type is not SetState<ThreadSearchState>?

66

Are you sure we should use it here? Not pass callback from parent component how to handle navigating?

81

It will work but since renderItem is defined as a function I would stick to React.useCallback

93

Maybe I am missing something but are we really want to show this placeholder even for searching for threads?

This revision now requires changes to proceed.Dec 22 2022, 6:31 AM
native/chat/thread-list-modal.react.js
66

Yeah, I really don't think anyone will want to use this modal to navigate somewhere else than to a thread.

81

We have an eslint rule that says useCallback has to be passed an inline. It seems that the community uses useMemo in cases like this.

kamil added a reviewer: tomek.
tomek added inline comments.
native/chat/sidebar-list-modal.react.js
34–37 ↗(On Diff #20148)

It is just a number so it doesn't need to be a memo

native/chat/thread-list-modal.react.js
31–35 ↗(On Diff #20148)

Can we use read only here?

This revision is now accepted and ready to land.Dec 29 2022, 12:47 AM

Address code review, rebase