mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 03:19:10 +00:00
FIX: properly handle invalid auto close date for polls
This commit is contained in:
parent
d8063d09d5
commit
5d445fb810
@ -118,7 +118,10 @@ export default Ember.Controller.extend({
|
||||
if (pollMax) pollHeader += ` max=${pollMax}`;
|
||||
if (isNumber) pollHeader += ` step=${step}`;
|
||||
if (publicPoll) pollHeader += ` public=true`;
|
||||
if (autoClose) pollHeader += ` close=${moment(date + " " + time, "YYYY-MM-DD HH:mm").toISOString()}`;
|
||||
if (autoClose) {
|
||||
let closeDate = moment(date + " " + time, "YYYY-MM-DD HH:mm").toISOString();
|
||||
if (closeDate) pollHeader += ` close=${closeDate}`;
|
||||
}
|
||||
|
||||
pollHeader += ']';
|
||||
output += `${pollHeader}\n`;
|
||||
@ -186,7 +189,7 @@ export default Ember.Controller.extend({
|
||||
pollMax: null,
|
||||
pollStep: 1,
|
||||
autoClose: false,
|
||||
date: moment().add(1, "day").format("YYYY-DD-MM"),
|
||||
date: moment().add(1, "day").format("YYYY-MM-DD"),
|
||||
time: moment().add(1, "hour").format("HH:mm"),
|
||||
});
|
||||
},
|
||||
|
@ -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>`
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user