FIX: properly handle invalid auto close date for polls

This commit is contained in:
Régis Hanol
2018-06-12 15:31:09 +02:00
parent d8063d09d5
commit 5d445fb810
2 changed files with 12 additions and 7 deletions

View File

@ -354,12 +354,14 @@ createWidget('discourse-poll-info', {
if (poll.close) {
const closeDate = moment.utc(poll.close);
const title = closeDate.format("LLL");
const timeLeft = moment().to(closeDate.local(), true);
if (closeDate.isValid()) {
const title = closeDate.format("LLL");
const timeLeft = moment().to(closeDate.local(), true);
result.push(new RawHtml({
html: `<span class="info-text" title="${title}">${I18n.t("poll.automatic_close.closes_in", { timeLeft })}</span>`
}));
result.push(new RawHtml({
html: `<span class="info-text" title="${title}">${I18n.t("poll.automatic_close.closes_in", { timeLeft })}</span>`
}));
}
}
}