Chats: clicking the profile message button calls onMessage
This commit is contained in:
parent
efa6f94cdd
commit
9a3aab27c9
4 changed files with 25 additions and 1 deletions
|
@ -14,6 +14,10 @@ export const CHAT_MESSAGE_SEND_REQUEST = 'CHAT_MESSAGE_SEND_REQUEST';
|
||||||
export const CHAT_MESSAGE_SEND_SUCCESS = 'CHAT_MESSAGE_SEND_SUCCESS';
|
export const CHAT_MESSAGE_SEND_SUCCESS = 'CHAT_MESSAGE_SEND_SUCCESS';
|
||||||
export const CHAT_MESSAGE_SEND_FAIL = 'CHAT_MESSAGE_SEND_FAIL';
|
export const CHAT_MESSAGE_SEND_FAIL = 'CHAT_MESSAGE_SEND_FAIL';
|
||||||
|
|
||||||
|
export const CHAT_FETCH_REQUEST = 'CHAT_FETCH_REQUEST';
|
||||||
|
export const CHAT_FETCH_SUCCESS = 'CHAT_FETCH_SUCCESS';
|
||||||
|
export const CHAT_FETCH_FAIL = 'CHAT_FETCH_FAIL';
|
||||||
|
|
||||||
export function fetchChats() {
|
export function fetchChats() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch({ type: CHATS_FETCH_REQUEST });
|
dispatch({ type: CHATS_FETCH_REQUEST });
|
||||||
|
@ -95,3 +99,14 @@ export function toggleMainWindow() {
|
||||||
return dispatch(changeSetting(['chats', 'mainWindow'], state));
|
return dispatch(changeSetting(['chats', 'mainWindow'], state));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function startChat(accountId) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
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 });
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch({ type: CHAT_FETCH_FAIL, accountId, error });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -294,7 +294,7 @@ class Header extends ImmutablePureComponent {
|
||||||
<div className='account__header__extra__buttons'>
|
<div className='account__header__extra__buttons'>
|
||||||
<ActionButton account={account} />
|
<ActionButton account={account} />
|
||||||
{account.get('id') !== me &&
|
{account.get('id') !== me &&
|
||||||
<Button className='button button-alternative-2' onClick={this.props.onDirect}>
|
<Button className='button-alternative-2' onClick={this.props.onMessage}>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='account.message' defaultMessage='Message' values={{
|
id='account.message' defaultMessage='Message' values={{
|
||||||
name: account.get('acct'),
|
name: account.get('acct'),
|
||||||
|
|
|
@ -72,6 +72,11 @@ export default class Header extends ImmutablePureComponent {
|
||||||
this.props.onUnblockDomain(domain);
|
this.props.onUnblockDomain(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleMessage = () => {
|
||||||
|
this.props.onMessage(this.props.account, this.context.router.history);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// handleEndorseToggle = () => {
|
// handleEndorseToggle = () => {
|
||||||
// this.props.onEndorseToggle(this.props.account);
|
// this.props.onEndorseToggle(this.props.account);
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -22,6 +22,7 @@ import { blockDomain, unblockDomain } from '../../../actions/domain_blocks';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import { List as ImmutableList } from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
import { getSettings } from 'soapbox/actions/settings';
|
import { getSettings } from 'soapbox/actions/settings';
|
||||||
|
import { startChat } from 'soapbox/actions/chats';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
|
unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
|
||||||
|
@ -133,6 +134,9 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onMessage(account, router) {
|
||||||
|
dispatch(startChat(account.get('id')));
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Header));
|
export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Header));
|
||||||
|
|
Loading…
Reference in a new issue