Limit the number of channels displayed on the index page

This commit is contained in:
calzoneman 2016-05-21 16:59:28 -07:00
parent beb99c5632
commit aedd0df228
5 changed files with 17 additions and 3 deletions

View file

@ -1,6 +1,6 @@
import { sendJade } from '../jade';
export default function initialize(app, channelIndex) {
export default function initialize(app, channelIndex, maxEntries) {
app.get('/', (req, res) => {
channelIndex.listPublicChannels().then((channels) => {
channels.sort((a, b) => {
@ -11,6 +11,8 @@ export default function initialize(app, channelIndex) {
return b.usercount - a.usercount;
});
channels = channels.slice(0, maxEntries);
sendJade(res, 'index', {
channels: channels
});

View file

@ -168,7 +168,7 @@ module.exports = {
}
require('./routes/channel')(app, ioConfig);
require('./routes/index')(app, channelIndex);
require('./routes/index')(app, channelIndex, webConfig.getMaxIndexEntries());
app.get('/sioconfig(.json)?', handleLegacySocketConfig);
require('./routes/socketconfig')(app, clusterClient);
app.get('/useragreement', handleUserAgreement);