Skip to content

Commit

Permalink
Merge pull request #2676 from gitcoinco/infinite-expire
Browse files Browse the repository at this point in the history
Fix never expires
  • Loading branch information
SaptakS authored Nov 12, 2018
2 parents 68320db + 3d4fdf1 commit 0d08313
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/assets/v2/js/pages/bounty_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ var callbacks = {

$('.progress').css('width', expiringInPercentage + '%');
var response = timeDifference(now, expires_date).split(' ');
const isInfinite = expires_date - new Date().setFullYear(new Date().getFullYear() + 1) > 1;

if (expires_date < new Date()) {
label = 'expired';
Expand All @@ -344,6 +345,8 @@ var callbacks = {
}
} else if (result['status'] === 'done' || result['status'] === 'cancelled') {
$('#timer').hide();
} else if (isInfinite) {
response = '&infin;';
} else {
response.shift();
response = response.join(' ');
Expand Down
14 changes: 11 additions & 3 deletions app/assets/v2/js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,7 @@ function renderBountyRowsFromResults(results, renderForExplorer) {
const dateNow = new Date();
const dateExpires = new Date(result['expires_date']);
const isExpired = dateExpires < dateNow && !result['is_open'];
const isInfinite = dateExpires - new Date().setFullYear(new Date().getFullYear() + 1) > 1;
const projectType = ucwords(result['project_type']) + ' &bull; ';

result['action'] = result['url'];
Expand Down Expand Up @@ -1104,10 +1105,17 @@ function renderBountyRowsFromResults(results, renderForExplorer) {
result['p'] += ('Expired ' + timeAgo + ' ago');
} else {
const openedWhen = timeDifference(dateNow, new Date(result['web3_created']), true);
const timeLeft = timeDifference(dateNow, dateExpires);
const expiredExpires = dateNow < dateExpires ? 'Expires' : 'Expired';

result['p'] += ('Opened ' + openedWhen + ' ago, ' + expiredExpires + ' ' + timeLeft);
if (isInfinite) {
const expiredExpires = 'Never expires';

result['p'] += ('Opened ' + openedWhen + ' ago, ' + expiredExpires);
} else {
const timeLeft = timeDifference(dateNow, dateExpires);
const expiredExpires = dateNow < dateExpires ? 'Expires' : 'Expired';

result['p'] += ('Opened ' + openedWhen + ' ago, ' + expiredExpires + ' ' + timeLeft);
}
}

if (renderForExplorer) {
Expand Down

0 comments on commit 0d08313

Please sign in to comment.