HomePhabricator
Diffusion Comm 6d785dcbf345

[web] Add community drawer item handlers

Description

[web] Add community drawer item handlers

Summary:
Linear issue: https://linear.app/comm/issue/ENG-2650/make-the-calendar-change-on-community-drawer-action
Pressing an item in the community drawer on web should result in different behaviour depending on the app the user has currently open. In chat it is supposed to open the corresponding chat. In calendar it is supposed to update the filters so that only the events of the corresponding chat are displayed. In Apps it is supposed to navigate back to the Chat tab and open the corresponding chat.
We took the following approach: we have a "map" from tab names to Handler components. The component takes a 'setHandler' function from its parent. The component performs some operations - like calling hooks, and creates a handler object. It then puts the handler object via setHandler in the parent component's state. This handler object is of CommunityDrawerItemHandlerSpec type, so it implements all functions that are needed by the drawer in each tab (that are specific to the tab).

Lastly - the access to this "map" of Handlers is gated by the getCommunityDrawerItemSpec function, because we assume there might be more apps in the future, and some of them (like Apps tab for now) might not want to have any custom behaviour defined for pressing a drawer item, but use the default - navigating to Chat tab and opening the corresponding chat.
getCommunityDrawerItemSpec function takes care of that "fallback", so that the calling code doesn't have to consider this.

Test Plan: Check that getCommunityDrawerItemSpec returns the correct component for each app by hand running the handler is sets for the parent.

Reviewers: tomek

Reviewed By: tomek

Subscribers: ashoat, atul

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

Details

Provenance
InkaSokolowskaAuthored on Feb 14 2023, 12:16 AM
Reviewer
tomek
Differential Revision
D6287: [web] Add community drawer item handlers
Parents
rCOMM7df7e152fcd0: [web] Add tab to payload for navigating to a chat
Branches
Unknown
Tags
Unknown