discourse/app/assets/javascripts/admin/controllers/admin-email-logs.js.es6

37 lines
868 B
Plaintext
Raw Normal View History

2018-06-15 23:03:24 +08:00
import EmailLog from "admin/models/email-log";
export default Ember.Controller.extend({
2016-03-25 23:37:26 +08:00
loading: false,
loadLogs(sourceModel, loadMore) {
if ((loadMore && this.get("loading")) || this.get("model.allLoaded")) {
return;
}
this.set("loading", true);
sourceModel = sourceModel || EmailLog;
2016-03-25 23:37:26 +08:00
return sourceModel
.findAll(this.get("filter"), loadMore ? this.get("model.length") : null)
.then(logs => {
if (this.get("model") && loadMore && logs.length < 50) {
this.get("model").set("allLoaded", true);
}
if (this.get("model") && loadMore) {
2018-06-15 23:03:24 +08:00
this.get("model").addObjects(logs);
} else {
this.set("model", logs);
}
})
.finally(() => this.set("loading", false));
},
actions: {
loadMore() {
this.loadLogs(EmailLog, true);
2016-03-25 23:37:26 +08:00
}
}
});