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.
This commit is contained in:
Martin Brennan 2021-09-23 11:18:49 +10:00 committed by GitHub
parent 38b8eb5971
commit 57f17854fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

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