diff --git a/web/app/assets/javascripts/sessionList.js b/web/app/assets/javascripts/sessionList.js index 20fc83c53..f615f3774 100644 --- a/web/app/assets/javascripts/sessionList.js +++ b/web/app/assets/javascripts/sessionList.js @@ -19,6 +19,7 @@ var $musicianTemplate = $('#template-musician-info'); var showJoinLink = true; var showListenLink = true; + var MAX_MINUTES_SHOW_START = 15; // related to listen function stateChange(e, data) { @@ -360,6 +361,13 @@ var noLinkText = ''; $('.rsvp-link-text', $parentRow).hide(); + function showStartSessionButton(scheduledStart) { + var now = new Date(); + var scheduledDate = new Date(scheduledStart); + var minutesFromStart = (scheduledDate.getTime() - now.getTime()) / (1000 * 60); + return minutesFromStart <= MAX_MINUTES_SHOW_START; + }; + if (session.creator.id === context.JK.currentUserId) { showRsvpLink = false; noLinkText = $('Start session now?'); @@ -370,13 +378,17 @@ } else if (approvedRsvpId) { showRsvpLink = false; - noLinkText = $('Start session now? | Cancel RSVP'); - // wire start link - noLinkText.find('a.start').click(function() { - ui.launchSessionStartDialog(session); - return false; - }); + if (showStartSessionButton(session.scheduled_start)) { + noLinkText = $('Start session now? | Cancel RSVP'); + noLinkText.find('a.start').click(function() { + ui.launchSessionStartDialog(session); + return false; + }); + } + else { + noLinkText = $('Cancel RSVP'); + } // wire cancel link noLinkText.find('a.cancel').click(function() { @@ -395,11 +407,14 @@ } else if (hasInvitation) { showRsvpLink = false; - noLinkText = $('Start session now?'); - noLinkText.find('a').click(function() { - ui.launchSessionStartDialog(session); - return false; - }); + + if (showStartSessionButton(session.scheduled_start)) { + noLinkText = $('Start session now?'); + noLinkText.find('a').click(function() { + ui.launchSessionStartDialog(session); + return false; + }); + } } else if (pendingRsvpId) { showRsvpLink = false; diff --git a/web/app/views/dialogs/_sessionStartDialog.html.slim b/web/app/views/dialogs/_sessionStartDialog.html.slim index e9695cb6c..5117beca0 100644 --- a/web/app/views/dialogs/_sessionStartDialog.html.slim +++ b/web/app/views/dialogs/_sessionStartDialog.html.slim @@ -25,7 +25,7 @@ h3.mt20 What instruments/parts do you need? .left.ib.w20.mt5 Me: #session-instruments-me-disp.left.ib.w75.mt5 - .clearall.left.ib.w20 Others: + .clearall.left.ib.w20.mt5 Others: #session-instruments-rsvp-disp.left.ib.w75.mt5 br clear='all'