Fix regressions related to deleting posts

- On the front-end, correct the check to see if the discussion has no more posts
- On the back-end, run a query to count the posts instead of using the comments_count, because the comments_count does not include other deleted posts
This commit is contained in:
Toby Zerner 2016-02-29 18:41:27 +10:30
parent 594a2ba8cc
commit cdbc4b9717
3 changed files with 3 additions and 3 deletions

View File

@ -33899,7 +33899,7 @@ System.register('flarum/utils/PostControls', ['flarum/components/EditPostCompose
// If this was the last post in the discussion, then we will assume that
// the whole discussion was deleted too.
if (!discussion.posts.length) {
if (!discussion.postIds().length) {
// If there is a discussion list in the cache, remove this discussion.
if (app.cache.discussionList) {
app.cache.discussionList.removeDiscussion(discussion);

View File

@ -155,7 +155,7 @@ export default {
// If this was the last post in the discussion, then we will assume that
// the whole discussion was deleted too.
if (!discussion.posts.length) {
if (!discussion.postIds().length) {
// If there is a discussion list in the cache, remove this discussion.
if (app.cache.discussionList) {
app.cache.discussionList.removeDiscussion(discussion);

View File

@ -54,7 +54,7 @@ class DiscussionMetadataUpdater
$discussion = $event->post->discussion;
if ($discussion->comments_count === 0) {
if ($discussion->posts()->count() === 0) {
$discussion->delete();
}
}