Ghost/ghost/admin/app/adapters/newsletter.js
Simon Backx 93632349b9 Fixed newsletter includes when adding or editing (#2365)
refs https://github.com/TryGhost/Team/issues/1571

- When creating a new newsletter, the counts were not loaded
- When updating a newsletter, the counts were not updated
- Requires https://github.com/TryGhost/Ghost/pull/14696
2022-05-05 11:31:45 +02:00

19 lines
654 B
JavaScript

import ApplicationAdapter from 'ghost-admin/adapters/application';
export default class Newsletter extends ApplicationAdapter {
buildIncludeURL(store, modelName, id, snapshot, requestType, query) {
const url = this.buildURL(modelName, id, snapshot, requestType, query);
const parsedUrl = new URL(url);
if (snapshot?.adapterOptions?.optInExisting) {
parsedUrl.searchParams.append('opt_in_existing', 'true');
}
if (snapshot?.adapterOptions?.include) {
parsedUrl.searchParams.append('include', snapshot?.adapterOptions?.include);
}
return parsedUrl.toString();
}
}