From 55950327fb49ee94b1c57d3f4d4536b631f86e80 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Sat, 21 Jun 2014 10:55:38 +0300 Subject: [PATCH] currentEvent ninja edit --- schedule.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/schedule.js b/schedule.js index ec16dd4..b4ec376 100644 --- a/schedule.js +++ b/schedule.js @@ -19,13 +19,13 @@ function Schedule() { } this.currentEvent = function() { + var latestEvent = _.last(this.pastEvents()); var nextEvent = this.nextEvent(); - - return _.last( - _.select(this.pastEvents(), function(event) { - return event.startTime.isAfter(nextEvent.startTime.subtract('20', 'minutes')); - }) - ); + if (typeof nextEvent != 'undefined' && nextEvent.startTime.subtract('10', 'minutes').isAfter(moment())) { + return latestEvent; + } else { + return undefined; + } } this.futureEvents = function() {