From 57f17854fb93e2d88c7b4eddc040338530c98239 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Thu, 23 Sep 2021 11:18:49 +1000 Subject: [PATCH] FIX: Do not error _removeDeleteOnOwnerReplyBookmarks on navigate (#14426) When creating a reply after already navigating out of the topic (e.g. open the reply composer, go to a different topic, then create the post), the _removeDeleteOnOwnerReplyBookmarks function was erroring because it relied on the topic model being present. We can skip this function altogether if the topic model is _not_ present, because the PostCreator already takes care of deleting bookmarks with the on_owner_reply auto_delete_preference. The _removeDeleteOnOwnerReplyBookmarks function just cleans up the in-memory post stream and topic model. --- app/assets/javascripts/discourse/app/controllers/topic.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/assets/javascripts/discourse/app/controllers/topic.js b/app/assets/javascripts/discourse/app/controllers/topic.js index 42db37f14f6..8f83a5e8805 100644 --- a/app/assets/javascripts/discourse/app/controllers/topic.js +++ b/app/assets/javascripts/discourse/app/controllers/topic.js @@ -211,6 +211,14 @@ export default Controller.extend(bufferedProperty("model"), { }, _removeDeleteOnOwnerReplyBookmarks() { + // the user has already navigated away from the topic. the PostCreator + // in rails already handles deleting the bookmarks that need to be + // based on auto_delete_preference; this is mainly used to clean up + // the in-memory post stream and topic model + if (!this.model) { + return; + } + const posts = this.get("model.postStream.posts"); if (posts) { posts