mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user