2018-06-15 11:03:24 -04:00
|
|
|
import IncomingEmail from "admin/models/incoming-email";
|
2016-01-18 18:57:55 -05:00
|
|
|
|
|
|
|
export default Ember.Controller.extend({
|
2016-03-25 11:37:26 -04:00
|
|
|
loading: false,
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
loadMore() {
|
2018-06-15 11:03:24 -04:00
|
|
|
if (this.get("loading") || this.get("model.allLoaded")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.set("loading", true);
|
2016-03-25 11:37:26 -04:00
|
|
|
|
|
|
|
IncomingEmail.findAll(this.get("filter"), this.get("model.length"))
|
2018-06-15 11:03:24 -04:00
|
|
|
.then(incoming => {
|
|
|
|
if (incoming.length < 50) {
|
|
|
|
this.get("model").set("allLoaded", true);
|
|
|
|
}
|
|
|
|
this.get("model").addObjects(incoming);
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.set("loading", false);
|
|
|
|
});
|
2016-03-25 11:37:26 -04:00
|
|
|
}
|
2016-01-18 18:57:55 -05:00
|
|
|
}
|
|
|
|
});
|