combine.fm/routes/index.js

20 lines
655 B
JavaScript
Raw Normal View History

2015-06-03 21:45:54 -07:00
import React from 'react';
2016-01-09 15:10:28 +00:00
import { renderPage } from '../lib/react-handler';
2015-08-20 23:22:57 +01:00
import { routes } from '../views/app';
2014-12-15 12:49:17 +00:00
2015-08-20 23:22:57 +01:00
export default function* () {
const recents = [];
const docs = yield this.db.matches.find().sort({'created_at': -1}).limit(6).toArray();
2015-06-03 21:45:54 -07:00
docs.forEach(function(doc) {
let shares = Object.keys(doc.services).map(function (key) {return doc.services[key]; });
shares.some(function(item) {
if (item.service === doc._id.split('$$')[0]) { // eslint-disable-line no-underscore-dangle
recents.push(item);
return false;
}
});
2014-12-15 12:49:17 +00:00
});
2015-06-03 21:45:54 -07:00
2016-01-09 15:10:28 +00:00
yield renderPage(routes, this.request.url, {recents: recents});
2015-05-17 19:10:30 +01:00
};