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.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", {
|
||||
data: {last_seen_at: last_seen_at}
|
||||
data: {last_seen_at: lastSeenAt}
|
||||
}).then(function (result) {
|
||||
return Discourse.EmailPreview.create(result);
|
||||
});
|
||||
|
|
|
@ -7,21 +7,17 @@
|
|||
@module Discourse
|
||||
**/
|
||||
|
||||
var oneWeekAgo = function() {
|
||||
return moment().subtract('days',7).format('YYYY-MM-DD');
|
||||
};
|
||||
|
||||
Discourse.AdminEmailPreviewDigestRoute = Discourse.Route.extend({
|
||||
|
||||
model: function() {
|
||||
return Discourse.EmailPreview.findDigest(oneWeekAgo());
|
||||
return Discourse.EmailPreview.findDigest();
|
||||
},
|
||||
|
||||
afterModel: function(model) {
|
||||
var controller = this.controllerFor('adminEmailPreviewDigest');
|
||||
controller.setProperties({
|
||||
model: model,
|
||||
lastSeen: oneWeekAgo(),
|
||||
lastSeen: moment().subtract('days',7).format('YYYY-MM-DD'),
|
||||
showHtml: true
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue