Chats: clicking the profile message button calls onMessage

loading-indicator-on-tls^2
Alex Gleason 2020-08-26 19:46:23 -05:00
rodzic efa6f94cdd
commit 9a3aab27c9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
4 zmienionych plików z 25 dodań i 1 usunięć

Wyświetl plik

@ -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_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() {
return (dispatch, getState) => {
dispatch({ type: CHATS_FETCH_REQUEST });
@ -95,3 +99,14 @@ export function toggleMainWindow() {
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 });
});
};
}

Wyświetl plik

@ -294,7 +294,7 @@ class Header extends ImmutablePureComponent {
<div className='account__header__extra__buttons'>
<ActionButton account={account} />
{account.get('id') !== me &&
<Button className='button button-alternative-2' onClick={this.props.onDirect}>
<Button className='button-alternative-2' onClick={this.props.onMessage}>
<FormattedMessage
id='account.message' defaultMessage='Message' values={{
name: account.get('acct'),

Wyświetl plik

@ -72,6 +72,11 @@ export default class Header extends ImmutablePureComponent {
this.props.onUnblockDomain(domain);
}
handleMessage = () => {
this.props.onMessage(this.props.account, this.context.router.history);
}
// handleEndorseToggle = () => {
// this.props.onEndorseToggle(this.props.account);
// }

Wyświetl plik

@ -22,6 +22,7 @@ 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';
const messages = defineMessages({
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));