FIX: Do not error _removeDeleteOnOwnerReplyBookmarks on navigate (#14426)

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.

diff --git a/app/assets/javascripts/discourse/app/controllers/topic.js b/app/assets/javascripts/discourse/app/controllers/topic.js
index 42db37f..8f83a5e 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) {

GitHub sha: 57f17854fb93e2d88c7b4eddc040338530c98239

This commit appears in #14426 which was approved by lis2. It was merged by martin.