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 });
|
dispatch({ type: CHAT_FETCH_REQUEST, accountId });
|
||||||
return api(getState).post(`/api/v1/pleroma/chats/by-account-id/${accountId}`).then(({ data }) => {
|
return api(getState).post(`/api/v1/pleroma/chats/by-account-id/${accountId}`).then(({ data }) => {
|
||||||
dispatch({ type: CHAT_FETCH_SUCCESS, chat: data });
|
dispatch({ type: CHAT_FETCH_SUCCESS, chat: data });
|
||||||
dispatch(openChat(data.id));
|
return data;
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
dispatch({ type: CHAT_FETCH_FAIL, accountId, 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 { 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';
|
import { startChat, openChat } from 'soapbox/actions/chats';
|
||||||
|
import { isMobile } from 'soapbox/is_mobile';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
|
unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
|
||||||
|
@ -128,14 +129,21 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
dispatch(unblockDomain(domain));
|
dispatch(unblockDomain(domain));
|
||||||
},
|
},
|
||||||
|
|
||||||
onAddToList(account){
|
onAddToList(account) {
|
||||||
dispatch(openModal('LIST_ADDER', {
|
dispatch(openModal('LIST_ADDER', {
|
||||||
accountId: account.get('id'),
|
accountId: account.get('id'),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
onChat(account, router) {
|
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;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue