FIX: Users can't "show all posts" in forced summary topics.

This commit is contained in:
Guo Xiang Tan 2018-06-22 11:32:45 +08:00
parent bad6a5142c
commit f69356e628
4 changed files with 19 additions and 4 deletions

View File

@ -178,9 +178,11 @@ export default function transformPost(
const postStream = topic.get("postStream");
postAtts.userFilters = postStream.userFilters;
postAtts.topicSummaryEnabled =
postStream.summary || topic.force_summary_mode;
if (topic.force_summary_mode) {
postStream.set('summary', topic.force_summary_mode);
}
postAtts.topicSummaryEnabled = postStream.summary;
postAtts.topicWordCount = topic.word_count;
postAtts.hasTopicSummary = topic.has_summary || topic.force_summary_mode;
}

View File

@ -108,6 +108,8 @@ export default RestModel.extend({
const result = {};
if (summary) {
result.filter = "summary";
} else {
result.filter = "none";
}
const userFilters = this.get("userFilters");

View File

@ -407,7 +407,9 @@ class TopicView
def force_summary_mode?
@force_summary_mode ||=
(@topic.closed? && @topic.posts_count >= (MEGA_TOPIC_POSTS_COUNT * 2))
@filter != 'none' &&
@topic.closed? &&
@topic.posts_count >= (MEGA_TOPIC_POSTS_COUNT * 2)
end
protected
@ -487,7 +489,9 @@ class TopicView
@filtered_posts = unfiltered_posts
# Filters
if @filter == 'summary' || ((@post_number.blank? || @post_number.to_i == 1) && force_summary_mode?)
if @filter == 'summary' ||
((@post_number.blank? || @post_number.to_i == 1) && force_summary_mode?)
@filtered_posts = @filtered_posts.summary(@topic.id)
@contains_gaps = true unless force_summary_mode?
end

View File

@ -391,6 +391,13 @@ describe TopicView do
expect(topic_view.contains_gaps?).to eq(false)
expect(topic_view.posts).to eq([p1, p2, p3])
end
it 'should not be forced into summary mode if filter is none' do
topic_view = TopicView.new(topic.id, evil_trout, filter: 'none')
expect(topic_view.contains_gaps?).to eq(false)
expect(topic_view.posts).to eq([p1, p2, p3])
end
end
it "#restricts to correct topic" do