FIX: add protection when removing auto delete on post bookmarks

If you reply to a topic and are looking at an admin page (like site settings)
,you have no postStream or posts.
This commit is contained in:
Sam Saffron 2020-07-29 16:42:24 +10:00
parent c7f1777ac9
commit 04a3b949a4
No known key found for this signature in database
GPG Key ID: B9606168D2FFD9F5
1 changed files with 13 additions and 11 deletions

View File

@ -189,17 +189,19 @@ export default Controller.extend(bufferedProperty("model"), {
},
_removeDeleteOnOwnerReplyBookmarks() {
let posts = this.model.get("postStream").posts;
posts
.filter(
p =>
p.bookmarked &&
p.bookmark_auto_delete_preference ===
AUTO_DELETE_PREFERENCES.ON_OWNER_REPLY
)
.forEach(p => {
p.clearBookmark();
});
const posts = this.get("model.postStream.posts");
if (posts) {
posts
.filter(
p =>
p.bookmarked &&
p.bookmark_auto_delete_preference ===
AUTO_DELETE_PREFERENCES.ON_OWNER_REPLY
)
.forEach(p => {
p.clearBookmark();
});
}
},
_forceRefreshPostStream() {