FIX: prevents double network calls and other quirks on admin emails (#7074)
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import AdminEmailLogsController from "admin/controllers/admin-email-logs";
|
||||
import debounce from "discourse/lib/debounce";
|
||||
import EmailLog from "admin/models/email-log";
|
||||
|
||||
export default AdminEmailLogsController.extend({
|
||||
filterEmailLogs: debounce(function() {
|
||||
EmailLog.findAll(this.get("filter")).then(logs => this.set("model", logs));
|
||||
}, 250).observes("filter.{user,address,type}")
|
||||
this.loadLogs();
|
||||
}, 250).observes("filter.{status,user,address,type}")
|
||||
});
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import IncomingEmail from "admin/models/incoming-email";
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
loading: false,
|
||||
|
||||
actions: {
|
||||
loadMore() {
|
||||
if (this.get("loading") || this.get("model.allLoaded")) {
|
||||
return;
|
||||
}
|
||||
this.set("loading", true);
|
||||
|
||||
IncomingEmail.findAll(this.get("filter"), this.get("model.length"))
|
||||
.then(incoming => {
|
||||
if (incoming.length < 50) {
|
||||
this.get("model").set("allLoaded", true);
|
||||
}
|
||||
this.get("model").addObjects(incoming);
|
||||
})
|
||||
.finally(() => {
|
||||
this.set("loading", false);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -3,23 +3,34 @@ import EmailLog from "admin/models/email-log";
|
||||
export default Ember.Controller.extend({
|
||||
loading: false,
|
||||
|
||||
loadLogs(sourceModel, loadMore) {
|
||||
if ((loadMore && this.get("loading")) || this.get("model.allLoaded")) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.set("loading", true);
|
||||
|
||||
sourceModel = sourceModel || EmailLog;
|
||||
|
||||
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) {
|
||||
this.get("model").addObjects(logs);
|
||||
} else {
|
||||
this.set("model", logs);
|
||||
}
|
||||
})
|
||||
.finally(() => this.set("loading", false));
|
||||
},
|
||||
|
||||
actions: {
|
||||
loadMore() {
|
||||
if (this.get("loading") || this.get("model.allLoaded")) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.set("loading", true);
|
||||
return EmailLog.findAll(this.get("filter"), this.get("model.length"))
|
||||
.then(logs => {
|
||||
if (logs.length < 50) {
|
||||
this.get("model").set("allLoaded", true);
|
||||
}
|
||||
this.get("model").addObjects(logs);
|
||||
})
|
||||
.finally(() => {
|
||||
this.set("loading", false);
|
||||
});
|
||||
this.loadLogs(EmailLog, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import AdminEmailIncomingsController from "admin/controllers/admin-email-incomings";
|
||||
import AdminEmailLogsController from "admin/controllers/admin-email-logs";
|
||||
import debounce from "discourse/lib/debounce";
|
||||
import IncomingEmail from "admin/models/incoming-email";
|
||||
|
||||
export default AdminEmailIncomingsController.extend({
|
||||
export default AdminEmailLogsController.extend({
|
||||
filterIncomingEmails: debounce(function() {
|
||||
IncomingEmail.findAll(this.get("filter")).then(incomings =>
|
||||
this.set("model", incomings)
|
||||
);
|
||||
}, 250).observes("filter.{from,to,subject}")
|
||||
this.loadLogs(IncomingEmail);
|
||||
}, 250).observes("filter.{status,from,to,subject}"),
|
||||
|
||||
actions: {
|
||||
loadMore() {
|
||||
this.loadLogs(IncomingEmail, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import AdminEmailIncomingsController from "admin/controllers/admin-email-incomings";
|
||||
import AdminEmailLogsController from "admin/controllers/admin-email-logs";
|
||||
import debounce from "discourse/lib/debounce";
|
||||
import IncomingEmail from "admin/models/incoming-email";
|
||||
|
||||
export default AdminEmailIncomingsController.extend({
|
||||
export default AdminEmailLogsController.extend({
|
||||
filterIncomingEmails: debounce(function() {
|
||||
IncomingEmail.findAll(this.get("filter")).then(incomings =>
|
||||
this.set("model", incomings)
|
||||
);
|
||||
}, 250).observes("filter.{from,to,subject,error}")
|
||||
this.loadLogs(IncomingEmail);
|
||||
}, 250).observes("filter.{status,from,to,subject,error}"),
|
||||
|
||||
actions: {
|
||||
loadMore() {
|
||||
this.loadLogs(IncomingEmail, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import AdminEmailLogsController from "admin/controllers/admin-email-logs";
|
||||
import debounce from "discourse/lib/debounce";
|
||||
import EmailLog from "admin/models/email-log";
|
||||
|
||||
export default AdminEmailLogsController.extend({
|
||||
filterEmailLogs: debounce(function() {
|
||||
EmailLog.findAll(this.get("filter")).then(logs => this.set("model", logs));
|
||||
}, 250).observes("filter.{user,address,type,reply_key}")
|
||||
this.loadLogs();
|
||||
}, 250).observes("filter.{status,user,address,type,reply_key}")
|
||||
});
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import AdminEmailLogsController from "admin/controllers/admin-email-logs";
|
||||
import debounce from "discourse/lib/debounce";
|
||||
import EmailLog from "admin/models/email-log";
|
||||
|
||||
export default AdminEmailLogsController.extend({
|
||||
filterEmailLogs: debounce(function() {
|
||||
EmailLog.findAll(this.get("filter")).then(logs => this.set("model", logs));
|
||||
}, 250).observes("filter.{user,address,type}")
|
||||
this.loadLogs();
|
||||
}, 250).observes("filter.{status,user,address,type}")
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user