sforkowany z mirror/soapbox
Chats: update "Message" button with conditional logic for mobile
rodzic
572a1db9f7
commit
7d0bd47ac1
|
@ -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 });
|
||||
});
|
||||
|
|
|
@ -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(() => {});
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -194,6 +194,7 @@
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue