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:
Jarek Radosz 2023-02-24 13:48:08 +01:00 committed by GitHub
parent 04659b0e41
commit d5cf128dbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -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(() => {

View File

@ -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",