DEV: Fix an error in topic deletion (#20440)
Spotted as log entry in tests: ``` TypeError: Cannot read properties of undefined (reading 'force_destroy') ```
This commit is contained in:
parent
04659b0e41
commit
d5cf128dbd
|
@ -1,4 +1,4 @@
|
|||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import Controller from "@ember/controller";
|
||||
import I18n from "I18n";
|
||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
import { action } from "@ember/object";
|
||||
|
@ -7,7 +7,6 @@ import discourseComputed from "discourse-common/utils/decorators";
|
|||
// Modal that displays confirmation text when user deletes a topic
|
||||
// The modal will display only if the topic exceeds a certain amount of views
|
||||
export default Controller.extend(ModalFunctionality, {
|
||||
topicController: controller("topic"),
|
||||
deletingTopic: false,
|
||||
|
||||
@discourseComputed("deletingTopic")
|
||||
|
@ -25,7 +24,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||
deleteTopic() {
|
||||
this.set("deletingTopic", true);
|
||||
|
||||
this.topicController.model
|
||||
this.model
|
||||
.destroy(this.currentUser)
|
||||
.then(() => this.send("closeModal"))
|
||||
.catch(() => {
|
||||
|
|
|
@ -453,7 +453,7 @@ const Topic = RestModel.extend({
|
|||
},
|
||||
|
||||
// Delete this topic
|
||||
destroy(deleted_by, opts) {
|
||||
destroy(deleted_by, opts = {}) {
|
||||
return ajax(`/t/${this.id}`, {
|
||||
data: { context: window.location.pathname, ...opts },
|
||||
type: "DELETE",
|
||||
|
|
Loading…
Reference in New Issue