diff --git a/app/soapbox/actions/chats.js b/app/soapbox/actions/chats.js index d9b97ea50..a3e743c87 100644 --- a/app/soapbox/actions/chats.js +++ b/app/soapbox/actions/chats.js @@ -127,7 +127,7 @@ export function startChat(accountId) { dispatch({ type: CHAT_FETCH_REQUEST, accountId }); return api(getState).post(`/api/v1/pleroma/chats/by-account-id/${accountId}`).then(({ data }) => { dispatch({ type: CHAT_FETCH_SUCCESS, chat: data }); - dispatch(openChat(data.id)); + return data; }).catch(error => { dispatch({ type: CHAT_FETCH_FAIL, accountId, error }); }); diff --git a/app/soapbox/features/account_timeline/containers/header_container.js b/app/soapbox/features/account_timeline/containers/header_container.js index 504675a42..6eebe0772 100644 --- a/app/soapbox/features/account_timeline/containers/header_container.js +++ b/app/soapbox/features/account_timeline/containers/header_container.js @@ -22,7 +22,8 @@ import { blockDomain, unblockDomain } from '../../../actions/domain_blocks'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { List as ImmutableList } from 'immutable'; import { getSettings } from 'soapbox/actions/settings'; -import { startChat } from 'soapbox/actions/chats'; +import { startChat, openChat } from 'soapbox/actions/chats'; +import { isMobile } from 'soapbox/is_mobile'; const messages = defineMessages({ unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' }, @@ -128,14 +129,21 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ dispatch(unblockDomain(domain)); }, - onAddToList(account){ + onAddToList(account) { dispatch(openModal('LIST_ADDER', { accountId: account.get('id'), })); }, onChat(account, router) { - dispatch(startChat(account.get('id'))); + // TODO make this faster + dispatch(startChat(account.get('id'))).then(chat => { + if (isMobile(window.innerWidth)) { + router.push(`/chats/${chat.id}`); + } else { + dispatch(openChat(chat.id)); + } + }).catch(() => {}); }, }); diff --git a/app/styles/chats.scss b/app/styles/chats.scss index 89268dfbe..6b4acab23 100644 --- a/app/styles/chats.scss +++ b/app/styles/chats.scss @@ -194,6 +194,7 @@ display: flex; flex-direction: column; overflow: hidden; + flex: 1; } } }