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

Failed to ignore revisions in .git-blame-ignore-revs.

38 lines
864 B
JavaScript
Raw Normal View History

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