kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Chats: Get chats from paneData
rodzic
d6b3268da4
commit
6e0bac3d43
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { injectIntl, FormattedMessage } from 'react-intl';
|
import { injectIntl } from 'react-intl';
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import { fetchChats } from 'soapbox/actions/chats';
|
import { fetchChats } from 'soapbox/actions/chats';
|
||||||
import ChatListAccount from './chat_list_account';
|
import ChatListAccount from './chat_list_account';
|
||||||
|
|
|
@ -7,10 +7,33 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import { getSettings } from 'soapbox/actions/settings';
|
import { getSettings } from 'soapbox/actions/settings';
|
||||||
import ChatList from './chat_list';
|
import ChatList from './chat_list';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
import { makeGetChat } from 'soapbox/selectors';
|
||||||
|
// import { fromJS } from 'immutable';
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const addChatsToPanes = (state, panesData) => {
|
||||||
panesData: getSettings(state).get('chats'),
|
const getChat = makeGetChat();
|
||||||
});
|
|
||||||
|
const newPanes = panesData.get('panes').map(pane => {
|
||||||
|
const chat = getChat(state, { id: pane.get('chat_id') });
|
||||||
|
return pane.set('chat', chat);
|
||||||
|
});
|
||||||
|
|
||||||
|
return panesData.set('panes', newPanes);
|
||||||
|
};
|
||||||
|
|
||||||
|
const mapStateToProps = state => {
|
||||||
|
const panesData = getSettings(state).get('chats');
|
||||||
|
|
||||||
|
// const panesData = fromJS({
|
||||||
|
// panes: [
|
||||||
|
// { chat_id: '9ySohyWw0Gecd3WHKK', state: 'open' },
|
||||||
|
// ],
|
||||||
|
// });
|
||||||
|
|
||||||
|
return {
|
||||||
|
panesData: addChatsToPanes(state, panesData),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export default @connect(mapStateToProps)
|
export default @connect(mapStateToProps)
|
||||||
@injectIntl
|
@injectIntl
|
||||||
|
@ -23,11 +46,13 @@ class ChatPanes extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderChatPane = (pane, i) => {
|
renderChatPane = (pane, i) => {
|
||||||
// const chat = getChat(pane.get('chat_id'))
|
const chat = pane.get('chat');
|
||||||
|
if (!chat) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={i} className='pane'>
|
<div key={i} className='pane'>
|
||||||
<div className='pane__header'>
|
<div className='pane__header'>
|
||||||
// {chat.getIn(['account', 'acct'])}
|
{chat.getIn(['account', 'acct'])}
|
||||||
</div>
|
</div>
|
||||||
<div className='pane__content'>
|
<div className='pane__content'>
|
||||||
// TODO: Show the chat messages
|
// TODO: Show the chat messages
|
||||||
|
|
Ładowanie…
Reference in New Issue