2023-10-11 02:38:59 +08:00
|
|
|
import { observes } from "@ember-decorators/object";
|
2020-03-11 22:28:16 +08:00
|
|
|
import { INPUT_DELAY } from "discourse-common/config/environment";
|
2020-12-18 21:18:52 +08:00
|
|
|
import discourseDebounce from "discourse-common/lib/debounce";
|
2023-10-11 02:38:59 +08:00
|
|
|
import AdminEmailLogsController from "admin/controllers/admin-email-logs";
|
2014-07-23 11:20:45 +08:00
|
|
|
|
2023-03-15 17:42:12 +08:00
|
|
|
export default class AdminEmailSentController extends AdminEmailLogsController {
|
2024-01-03 09:27:25 +08:00
|
|
|
ccAddressDisplayThreshold = 2;
|
|
|
|
sortWithAddressFilter = (addresses) => {
|
|
|
|
if (!Array.isArray(addresses) || addresses.length === 0) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
const targetEmail = this.filter.address;
|
|
|
|
|
|
|
|
if (!targetEmail) {
|
|
|
|
return addresses;
|
|
|
|
}
|
|
|
|
|
|
|
|
return addresses.sort((a, b) => {
|
|
|
|
if (a.includes(targetEmail) && !b.includes(targetEmail)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (!a.includes(targetEmail) && b.includes(targetEmail)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-01-17 01:56:53 +08:00
|
|
|
@observes("filter.{status,user,address,type,reply_key}")
|
2020-12-18 21:18:52 +08:00
|
|
|
filterEmailLogs() {
|
|
|
|
discourseDebounce(this, this.loadLogs, INPUT_DELAY);
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
|
|
|
}
|