Changeset View
Changeset View
Standalone View
Standalone View
web/sidebar/community-drawer-item-handlers.react.js
// @flow | // @flow | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { useDispatch } from 'react-redux'; | import { useDispatch } from 'react-redux'; | ||||
import { | |||||
updateCalendarThreadFilter, | |||||
calendarThreadFilterTypes, | |||||
} from 'lib/types/filter-types.js'; | |||||
import type { ThreadInfo } from 'lib/types/thread-types.js'; | import type { ThreadInfo } from 'lib/types/thread-types.js'; | ||||
import type { CommunityDrawerItemHandler } from './community-drawer-item-handler.react.js'; | import type { CommunityDrawerItemHandler } from './community-drawer-item-handler.react.js'; | ||||
import { updateCalendarCommunityFilter } from '../redux/action-types.js'; | |||||
import { | import { | ||||
useOnClickThread, | useOnClickThread, | ||||
useThreadIsActive, | useThreadIsActive, | ||||
} from '../selectors/thread-selectors.js'; | } from '../selectors/thread-selectors.js'; | ||||
import type { NavigationTab } from '../types/nav-types.js'; | import type { NavigationTab } from '../types/nav-types.js'; | ||||
type HandlerProps = { | type HandlerProps = { | ||||
+setHandler: (handler: CommunityDrawerItemHandler) => void, | +setHandler: (handler: CommunityDrawerItemHandler) => void, | ||||
Show All 15 Lines | function ChatDrawerItemHandler(props: HandlerProps): React.Node { | ||||
return null; | return null; | ||||
} | } | ||||
function CalendarDrawerItemHandler(props: HandlerProps): React.Node { | function CalendarDrawerItemHandler(props: HandlerProps): React.Node { | ||||
const { setHandler, threadInfo } = props; | const { setHandler, threadInfo } = props; | ||||
const dispatch = useDispatch(); | const dispatch = useDispatch(); | ||||
const onClick = React.useCallback( | const onClick = React.useCallback(() => { | ||||
() => | |||||
dispatch({ | dispatch({ | ||||
type: updateCalendarThreadFilter, | type: updateCalendarCommunityFilter, | ||||
payload: { | payload: threadInfo.id, | ||||
type: calendarThreadFilterTypes.THREAD_LIST, | }); | ||||
threadIDs: [threadInfo.id], | }, [dispatch, threadInfo.id]); | ||||
}, | |||||
}), | |||||
[dispatch, threadInfo.id], | |||||
); | |||||
const isActive = false; | const isActive = false; | ||||
const handler = React.useMemo(() => ({ onClick, isActive }), [ | const handler = React.useMemo(() => ({ onClick, isActive }), [ | ||||
onClick, | onClick, | ||||
isActive, | isActive, | ||||
]); | ]); | ||||
React.useEffect(() => { | React.useEffect(() => { | ||||
setHandler(handler); | setHandler(handler); | ||||
Show All 19 Lines |