Send irc features to the client
This commit is contained in:
parent
9267c661dc
commit
613d9fca6e
20 changed files with 690 additions and 304 deletions
|
@ -79,6 +79,7 @@ export default createCommandMiddleware(COMMAND, {
|
|||
topic({ dispatch, getState, server, channel }, ...newTopic) {
|
||||
if (newTopic.length > 0) {
|
||||
dispatch(setTopic(newTopic.join(' '), channel, server));
|
||||
return;
|
||||
} else if (channel) {
|
||||
const { topic } = getState().channels[server][channel];
|
||||
if (topic) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import React, { PureComponent } from 'react';
|
||||
import classnames from 'classnames';
|
||||
import get from 'lodash/get';
|
||||
import Button from 'components/ui/Button';
|
||||
import TabListItem from 'containers/TabListItem';
|
||||
|
||||
|
@ -39,13 +40,22 @@ export default class TabList extends PureComponent {
|
|||
/>
|
||||
);
|
||||
|
||||
let chanLabel;
|
||||
const chanLimit =
|
||||
get(srv.features, ['CHANLIMIT', '#'], 0) || srv.features.MAXCHANNELS;
|
||||
if (chanLimit > 0) {
|
||||
chanLabel = `CHANNELS (${server.channels.length}/${chanLimit})`;
|
||||
} else {
|
||||
chanLabel = `CHANNELS (${server.channels.length})`;
|
||||
}
|
||||
|
||||
tabs.push(
|
||||
<div
|
||||
key={`${address}-chans}`}
|
||||
className="tab-label"
|
||||
onClick={() => openModal('channel', { server: address })}
|
||||
>
|
||||
<span>CHANNELS ({server.channels.length})</span>
|
||||
<span>{chanLabel}</span>
|
||||
<Button>+</Button>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -16,7 +16,8 @@ describe('server reducer', () => {
|
|||
status: {
|
||||
connected: false,
|
||||
error: null
|
||||
}
|
||||
},
|
||||
features: {}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -30,7 +31,8 @@ describe('server reducer', () => {
|
|||
status: {
|
||||
connected: false,
|
||||
error: null
|
||||
}
|
||||
},
|
||||
features: {}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -47,7 +49,8 @@ describe('server reducer', () => {
|
|||
status: {
|
||||
connected: false,
|
||||
error: null
|
||||
}
|
||||
},
|
||||
features: {}
|
||||
},
|
||||
'127.0.0.2': {
|
||||
name: 'srv',
|
||||
|
@ -56,7 +59,8 @@ describe('server reducer', () => {
|
|||
status: {
|
||||
connected: false,
|
||||
error: null
|
||||
}
|
||||
},
|
||||
features: {}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -216,7 +220,8 @@ describe('server reducer', () => {
|
|||
editedNick: null,
|
||||
status: {
|
||||
connected: true
|
||||
}
|
||||
},
|
||||
features: {}
|
||||
},
|
||||
'127.0.0.2': {
|
||||
name: 'stuffz',
|
||||
|
@ -224,7 +229,8 @@ describe('server reducer', () => {
|
|||
editedNick: null,
|
||||
status: {
|
||||
connected: false
|
||||
}
|
||||
},
|
||||
features: {}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -247,7 +253,8 @@ describe('server reducer', () => {
|
|||
editedNick: null,
|
||||
status: {
|
||||
connected: true
|
||||
}
|
||||
},
|
||||
features: {}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -266,7 +273,8 @@ describe('server reducer', () => {
|
|||
status: {
|
||||
connected: false,
|
||||
error: 'Bad stuff happened'
|
||||
}
|
||||
},
|
||||
features: {}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -70,6 +70,7 @@ export const socket = createSocketActions([
|
|||
'channel_search',
|
||||
'connection_update',
|
||||
'error',
|
||||
'features',
|
||||
'join',
|
||||
'message',
|
||||
'mode',
|
||||
|
|
|
@ -45,7 +45,8 @@ export default createReducer(
|
|||
status: {
|
||||
connected: false,
|
||||
error: null
|
||||
}
|
||||
},
|
||||
features: {}
|
||||
};
|
||||
}
|
||||
},
|
||||
|
@ -79,8 +80,8 @@ export default createReducer(
|
|||
|
||||
[actions.socket.SERVERS](state, { data }) {
|
||||
if (data) {
|
||||
data.forEach(({ host, name, nick, status }) => {
|
||||
state[host] = { name, nick, status, editedNick: null };
|
||||
data.forEach(({ host, name = host, nick, status, features = {} }) => {
|
||||
state[host] = { name, nick, status, features, editedNick: null };
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -90,6 +91,17 @@ export default createReducer(
|
|||
state[server].status.connected = connected;
|
||||
state[server].status.error = error;
|
||||
}
|
||||
},
|
||||
|
||||
[actions.socket.FEATURES](state, { server, features }) {
|
||||
const srv = state[server];
|
||||
if (srv) {
|
||||
srv.features = features;
|
||||
|
||||
if (features.NETWORK && srv.name === server) {
|
||||
srv.name = features.NETWORK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue