DEV: Update composer service to inherit from Service, not Controller (#22929)

This was forgotten during the work in 22991bba44ffae62d72bdb833787f73f17a8f6bf

This revealed two differences we were depending on: the merged `actions` hash (re-implemented on the service), and a couple of calls to `composer.send` (now removed)
This commit is contained in:
David Taylor 2023-08-02 12:44:18 +01:00 committed by GitHub
parent e680437030
commit 17d5e3ec23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -450,7 +450,7 @@ export default Controller.extend(bufferedProperty("model"), {
} else if (composer.get("model.viewDraft")) {
const model = composer.get("model");
model.set("reply", model.get("reply") + "\n" + quotedText);
composer.send("openIfDraft");
composer.openIfDraft();
} else {
composer.open(composerOpts);
}

View File

@ -1,5 +1,4 @@
import Composer, { SAVE_ICONS, SAVE_LABELS } from "discourse/models/composer";
import Controller from "@ember/controller";
import EmberObject, { action, computed } from "@ember/object";
import { alias, and, or, reads } from "@ember/object/computed";
import {
@ -26,7 +25,7 @@ import { getOwner } from "discourse-common/lib/get-owner";
import getURL from "discourse-common/lib/get-url";
import { isEmpty } from "@ember/utils";
import { isTesting } from "discourse-common/config/environment";
import { inject as service } from "@ember/service";
import Service, { inject as service } from "@ember/service";
import { shortDate } from "discourse/lib/formatter";
import showModal from "discourse/lib/show-modal";
import { categoryBadgeHTML } from "discourse/helpers/category-link";
@ -95,7 +94,7 @@ export function addComposerSaveErrorCallback(callback) {
_composerSaveErrorCallbacks.push(callback);
}
export default class ComposerController extends Controller {
export default class ComposerService extends Service {
@service router;
@service dialog;
@service site;
@ -1681,3 +1680,7 @@ export default class ComposerController extends Controller {
this.set("lastValidatedAt", null);
}
}
// For compatibility with themes/plugins which use `modifyClass` as if this is a controller
// https://api.emberjs.com/ember/5.1/classes/Service/properties/mergedProperties?anchor=mergedProperties
ComposerService.prototype.mergedProperties = ["actions"];

View File

@ -427,7 +427,6 @@ export default Component.extend({
},
_closeModal() {
const composer = getOwner(this).lookup("controller:composer");
composer.send("closeModal");
getOwner(this).lookup("service:modal").close();
},
});