diff --git a/src/controllers/api/channel/listController.js b/src/controllers/api/channel/listController.js
index 378df55..e55ea61 100644
--- a/src/controllers/api/channel/listController.js
+++ b/src/controllers/api/channel/listController.js
@@ -21,6 +21,7 @@ const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
//api account functions
module.exports.get = async function(req, res){
try{
+ //We pull this from the DB insteada activeChannels because we want to list channels that arent active after server restarts
const chanGuide = await channelModel.getChannelList();
res.status(200);
diff --git a/src/controllers/indexController.js b/src/controllers/indexController.js
index 537656f..7c96e82 100644
--- a/src/controllers/indexController.js
+++ b/src/controllers/indexController.js
@@ -25,8 +25,7 @@ const {exceptionHandler, errorHandler} = require('../utils/loggerUtils');
//root index functions
module.exports.get = async function(req, res){
try{
- const chanGuide = await channelModel.getChannelList();
- return navRender.render(req, res, 'index', {chanGuide: chanGuide, unescape: validator.unescape})
+ return navRender.render(req, res, 'index', {unescape: validator.unescape})
}catch(err){
return exceptionHandler(res, err);
}
diff --git a/src/routers/api/channelRouter.js b/src/routers/api/channelRouter.js
index 0e1a1ed..41290ed 100644
--- a/src/routers/api/channelRouter.js
+++ b/src/routers/api/channelRouter.js
@@ -66,7 +66,7 @@ router.post('/thumbnail', channelValidator.thumbnail(), thumbnailController.post
router.get('/description', descriptionController.get);
router.post('/description', channelValidator.description(), descriptionController.post);
//list
-router.get('/list', channelModel.reqPermCheck("manageChannel"), listController.get);
+router.get('/list', listController.get);
//settings
router.get('/settings', channelModel.reqPermCheck("manageChannel"), settingsController.get);
router.post('/settings', channelModel.reqPermCheck("changeSettings"), channelValidator.settingsMap(), settingsController.post);
diff --git a/src/schemas/channel/channelSchema.js b/src/schemas/channel/channelSchema.js
index bd02fe0..3976870 100644
--- a/src/schemas/channel/channelSchema.js
+++ b/src/schemas/channel/channelSchema.js
@@ -284,9 +284,10 @@ channelSchema.statics.register = async function(channelObj, ownerObj){
/**
* Generates Network-Friendly Browser-Digestable list of channels
* @param {Boolean} includeHidden - Whether or not to include hidden channels within the list
+ * @param {Date} endDate - Limits amount of scheduled items sent, defaults to 90 minutes
* @returns {Array} List of Network-Friendly Browser-Digestable Objects representing channels on the server
*/
-channelSchema.statics.getChannelList = async function(includeHidden = false){
+channelSchema.statics.getChannelList = async function(includeHidden = false, endDate = new Date(Date.now() + (1000 * 60 * 90))){
const chanDB = await this.find({});
var chanGuide = [];
@@ -294,12 +295,32 @@ channelSchema.statics.getChannelList = async function(includeHidden = false){
chanDB.forEach((channel) => {
//For each channel, push an object with only the information we need to the channel guide
if(!channel.settings.hidden || includeHidden){
- chanGuide.push({
+ //Create freeze-dried channel entry object (just add bong water)
+ const entry = {
id: channel.id,
name: channel.name,
description: channel.description,
- thumbnail: channel.thumbnail
- });
+ thumbnail: channel.thumbnail,
+ schedule: []
+ }
+
+ //If we're currently playing something
+ if(channel.media.nowPlaying != null){
+ //Toss the currently playing item on
+ entry.schedule.push(channel.media.nowPlaying);
+ }
+
+ //For every piece of scehduled media for this channel
+ for(const media of channel.media.scheduled){
+ //If it starts before our cut-off
+ if(endDate.getTime() > media.startTime){
+ //Add that shit, son!
+ entry.schedule.push(media);
+ }
+ }
+
+ //add the channel entry to our return array
+ chanGuide.push(entry);
}
});
diff --git a/src/views/index.ejs b/src/views/index.ejs
index b2932b1..637b545 100644
--- a/src/views/index.ejs
+++ b/src/views/index.ejs
@@ -18,25 +18,14 @@ along with this program. If not, see