HomePhabricator
Diffusion Comm f612d842fe83

[web] Extract from drawer item code that can be reused in community items

Description

[web] Extract from drawer item code that can be reused in community items

Summary:
isse: https://linear.app/comm/issue/ENG-3176/make-pressing-a-drawer-item-in-chat-tab-filter-available-chats
Because of changes to how the drawer is supposed to work I need to change how drawer items are implemented. Before, the only difference between items that represented community chats and other
chats was that community items shared the expanded state, as only one of them could be expanded at once, while other chats kept their own state each. This was implemented by having a
CommunityDrawerItem component that was wrapped by CommunityDrawerItemCommunity for community chats, and by CommunityDrawerItemChat for other chats. Those wrappers took care of the small
differences between the two types of drawer items.
But now, this task that I'm working on here makes the difference between the community items and other items so big, that it no longer makes sense for them to be wrappers of some shared
component. Insted they will be implemented as entierly separate components. The parts of the code that they can share are in this diff extraced from CommunityDrawerItem to
community-drawer-utils.react.js.

I wanted to just extract the common code in this diff, but to keep the code correct I had to introduce changes to CommunityDrawerItemCommunity as well, because of the following resons:

  1. We cannot export two components form one file
  2. CommunityDrawerItem and CommunityDrawerItemChat have to be in the same file
  3. The code extracted from CommunityDrawerItem requires the CommunityDrawerItemChat component, while the old implementation of CommunityDrawerItemCommunity required

CommunityDrawerItem
That's why this diff is so large, and includes making CommunityDrawerItemCommunity an entierly separate component from CommunityDrawerItem. To not make this diff any bigger I left
CommunityDrawerItemChat and CommunityDrawerItem as separate components, but since now CommunityDrawerItemChat is the only component that uses CommunityDrawerItem, and has no problem being
merged with it, they will be merged in following diffs

Test Plan:
Run web app,checked that drawer items work correctly: expand and navigate to chats in Chat tab, and change filters in Calendar tab. The highlight is supposed to not show up on community items,
since it will be entierly removed in the future, so I didn't implement it for the community items.

Reviewers: kamil, tomek, michal

Reviewed By: tomek, michal

Subscribers: ashoat, atul

Differential Revision: https://phab.comm.dev/D6973

Details