Chats: update "Message" button with conditional logic for mobile

loading-indicator-on-tls^2
Alex Gleason 2020-08-28 15:06:55 -05:00
rodzic 572a1db9f7
commit 7d0bd47ac1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
3 zmienionych plików z 13 dodań i 4 usunięć

Wyświetl plik

@ -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 });
});

Wyświetl plik

@ -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(() => {});
},
});

Wyświetl plik

@ -194,6 +194,7 @@
display: flex;
flex-direction: column;
overflow: hidden;
flex: 1;
}
}
}