Skip to content

Commit

Permalink
Fix @teesloane\'s eslint issues :E and load chats after config has be…
Browse files Browse the repository at this point in the history
…en updated (#78)
  • Loading branch information
mihok authored Sep 23, 2017
1 parent ab7c257 commit 470d1ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
27 changes: 14 additions & 13 deletions src/components/MessageList/MessageList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,42 @@ class MessageList extends Component {
}),
).isRequired,
chat: PropTypes.object.isRequired,
chats: PropTypes.object,
config: PropTypes.object.isRequired,
activeId: PropTypes.string,
dispatch: PropTypes.func.isRequired,
}

componentWillMount () {
const { activeId } = this.props;

if (this.props.config.apiServer && activeId) {
loadMessages(this.props.dispatch, this.props.config, activeId);
}
}

emptyRenderer () {
renderEmpty () {
if (Object.keys(this.props.chats).length === 0) {
return (
<div className="MessageList__empty">
<div className="ss-icon ss-ghost lil-ghost" />
<div>You have no chats!</div>
<div style={{fontSize: "12px", padding: "10px"}}>We still love you.</div>
<div style={{ fontSize: '12px', padding: '10px' }}>We still love you.</div>
</div>
);
}

if (this.props.chat.hasOwnProperty = "open") {
if (this.props.chat.hasOwnProperty('open')) {
return (
<div className="MessageList__empty">
<div className="ss-icon ss-mailbox lil-mailbox" />
<div>No chat selected</div>
<div style={{fontSize: "12px", padding: "10px"}}>Click a chat on the left to get started!</div>
<div style={{ fontSize: '12px', padding: '10px' }}>Click a chat on the left to get started!</div>
</div>
);
}
}

componentWillMount () {
const { activeId } = this.props;

if (this.props.config.apiServer && activeId) {
loadMessages(this.props.dispatch, this.props.config, activeId);
}
return null;
}

renderTyping () {
Expand Down Expand Up @@ -112,13 +114,12 @@ class MessageList extends Component {
}

render () {
window.props = this.props
const { messages, chat, activeId } = this.props;
const activeMsgs = messages.filter(msg => msg.chat === activeId);

// Render a map of <Message> components with their contents.
const renderView = () => {
if (!activeId) return this.emptyRenderer();
if (!activeId) return this.renderEmpty();

return activeMsgs.map((msg, index) => {
const key = `${index}_${msg.chat}`;
Expand Down
6 changes: 3 additions & 3 deletions src/init.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Application from './components/Application/Application.jsx';
import socketInit, { socketMessageHook } from './socket.js';

// Reducers
import chat from './store/Chat';
import chat, { loadChats } from './store/Chat';
import ui from './store/UI';
import config, { setConfig } from './store/Config';
import socket from './store/Socket';
Expand Down Expand Up @@ -38,12 +38,12 @@ ipcRenderer.on('config', (event, newConfig) => {

// Create Socket Connection only if there is a new apiServer config
if (newConfig.apiServer === state.config.apiServer) {
console.log('SOCKET', 'Already initialized, skipping ...');
return;
}

console.log('SOCKET', 'Initializing ...');
socketInit(store);

loadChats(dispatch, newConfig);
});

ipcRenderer.send('init-config');
Expand Down

0 comments on commit 470d1ca

Please sign in to comment.