FIX: Email preview with no date caused a server error
This commit is contained in:
parent
c18a6827df
commit
3bba75b052
|
@ -9,9 +9,14 @@
|
||||||
Discourse.EmailPreview = Discourse.Model.extend({});
|
Discourse.EmailPreview = Discourse.Model.extend({});
|
||||||
|
|
||||||
Discourse.EmailPreview.reopenClass({
|
Discourse.EmailPreview.reopenClass({
|
||||||
findDigest: function(last_seen_at) {
|
findDigest: function(lastSeenAt) {
|
||||||
|
|
||||||
|
if (Em.isEmpty(lastSeenAt)) {
|
||||||
|
lastSeenAt = moment().subtract('days',7).format('YYYY-MM-DD');
|
||||||
|
}
|
||||||
|
|
||||||
return Discourse.ajax("/admin/email/preview-digest.json", {
|
return Discourse.ajax("/admin/email/preview-digest.json", {
|
||||||
data: {last_seen_at: last_seen_at}
|
data: {last_seen_at: lastSeenAt}
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
return Discourse.EmailPreview.create(result);
|
return Discourse.EmailPreview.create(result);
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,21 +7,17 @@
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
|
|
||||||
var oneWeekAgo = function() {
|
|
||||||
return moment().subtract('days',7).format('YYYY-MM-DD');
|
|
||||||
};
|
|
||||||
|
|
||||||
Discourse.AdminEmailPreviewDigestRoute = Discourse.Route.extend({
|
Discourse.AdminEmailPreviewDigestRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
model: function() {
|
model: function() {
|
||||||
return Discourse.EmailPreview.findDigest(oneWeekAgo());
|
return Discourse.EmailPreview.findDigest();
|
||||||
},
|
},
|
||||||
|
|
||||||
afterModel: function(model) {
|
afterModel: function(model) {
|
||||||
var controller = this.controllerFor('adminEmailPreviewDigest');
|
var controller = this.controllerFor('adminEmailPreviewDigest');
|
||||||
controller.setProperties({
|
controller.setProperties({
|
||||||
model: model,
|
model: model,
|
||||||
lastSeen: oneWeekAgo(),
|
lastSeen: moment().subtract('days',7).format('YYYY-MM-DD'),
|
||||||
showHtml: true
|
showHtml: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue