|
1 | 1 | // @flow |
2 | 2 | import * as React from 'react'; |
3 | 3 | import { connect } from 'react-redux'; |
4 | | -import { Route, Link } from 'react-router-dom'; |
| 4 | +import { Route, Link, withRouter, type Location } from 'react-router-dom'; |
5 | 5 | import compose from 'recompose/compose'; |
6 | 6 | import type { Dispatch } from 'redux'; |
7 | 7 | import { Query, Mutation } from 'react-apollo'; |
@@ -39,9 +39,10 @@ type Props = { |
39 | 39 | dispatch: Dispatch<Object>, |
40 | 40 | currentUser: Object, |
41 | 41 | communitySlug: string, |
| 42 | + location: Location, |
42 | 43 | }; |
43 | 44 |
|
44 | | -const ChatTab = ({ community, currentUser }) => |
| 45 | +const ChatTab = ({ location, community, currentUser }) => |
45 | 46 | !community.watercoolerId ? null : ( |
46 | 47 | <Route exact path={`/${community.slug}`}> |
47 | 48 | {({ match }) => { |
@@ -161,6 +162,7 @@ class Component extends React.Component<Props> { |
161 | 162 | isLoading, |
162 | 163 | currentUser, |
163 | 164 | data: { community }, |
| 165 | + location, |
164 | 166 | } = this.props; |
165 | 167 |
|
166 | 168 | if (isLoading) { |
@@ -206,7 +208,11 @@ class Component extends React.Component<Props> { |
206 | 208 | </SidebarSectionHeader> |
207 | 209 |
|
208 | 210 | <List data-cy="channel-list"> |
209 | | - <ChatTab community={community} currentUser={currentUser} /> |
| 211 | + <ChatTab |
| 212 | + location={location} |
| 213 | + community={community} |
| 214 | + currentUser={currentUser} |
| 215 | + /> |
210 | 216 | <Route exact path={`/${community.slug}`}> |
211 | 217 | {({ match }) => ( |
212 | 218 | <Link to={`/${community.slug}?tab=posts`}> |
@@ -260,5 +266,6 @@ export const ChannelsList = compose( |
260 | 266 | getCommunityChannels, |
261 | 267 | viewNetworkHandler, |
262 | 268 | withCurrentUser, |
| 269 | + withRouter, |
263 | 270 | connect() |
264 | 271 | )(Component); |
0 commit comments