mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 09:50:37 -06:00
Option to supress replies button below a post, when its reply is directly following.
This commit is contained in:
parent
04c8b20840
commit
d7f3241285
@ -173,6 +173,27 @@ window.Discourse.Post = Ember.Object.extend Discourse.Presence,
|
||||
loadVersions: (callback) ->
|
||||
$.get "/posts/#{@get('id')}/versions.json", (result) -> callback(result)
|
||||
|
||||
|
||||
# Whether to show replies directly below
|
||||
showRepliesBelow: (->
|
||||
reply_count = @get('reply_count')
|
||||
|
||||
# We don't show replies if there aren't any
|
||||
return false if reply_count is 0
|
||||
|
||||
# Always show replies if the setting `supress_reply_directly_below` is false.
|
||||
return true unless Discourse.SiteSettings.supress_reply_directly_below
|
||||
|
||||
# Always show replies if there's more than one
|
||||
return true if reply_count > 1
|
||||
|
||||
# If we have *exactly* one reply, we have to consider if it's directly below us
|
||||
return false if @get('topic')?.isReplyDirectlyBelow(@)
|
||||
|
||||
true
|
||||
|
||||
).property('reply_count')
|
||||
|
||||
window.Discourse.Post.reopenClass
|
||||
|
||||
REGULAR_TYPE: <%= Post::REGULAR %>
|
||||
|
@ -243,6 +243,18 @@ Discourse.Topic = Discourse.Model.extend Discourse.Presence,
|
||||
newPosts.each (p)->
|
||||
posts.pushObject(p) unless map[p.get('post_number')]
|
||||
|
||||
# Is the reply to a post directly below it?
|
||||
isReplyDirectlyBelow: (post) ->
|
||||
posts = @get('posts')
|
||||
return unless posts
|
||||
|
||||
postBelow = posts[posts.indexOf(post) + 1]
|
||||
|
||||
# If the post directly below's reply_to_post_number is our post number, it's
|
||||
# considered directly below.
|
||||
return postBelow?.get('reply_to_post_number') is post.get('post_number')
|
||||
|
||||
|
||||
window.Discourse.Topic.reopenClass
|
||||
|
||||
NotificationLevel:
|
||||
|
@ -26,15 +26,13 @@ window.Discourse.PostMenuView = Ember.View.extend Discourse.Presence,
|
||||
# Trigger re rendering
|
||||
needsToRender: (->
|
||||
@rerender()
|
||||
).observes('post.deleted_at', 'post.flagsAvailable.@each', 'post.url', 'post.bookmarked', 'post.reply_count', 'post.can_delete')
|
||||
).observes('post.deleted_at', 'post.flagsAvailable.@each', 'post.url', 'post.bookmarked', 'post.reply_count', 'post.showRepliesBelow', 'post.can_delete')
|
||||
|
||||
# Replies Button
|
||||
renderReplies: (post, buffer) ->
|
||||
|
||||
return if @get('post.replyFollowing')
|
||||
|
||||
return unless post.get('showRepliesBelow')
|
||||
reply_count = post.get('reply_count')
|
||||
return if reply_count == 0
|
||||
|
||||
buffer.push("<button class='show-replies' data-action='replies'>")
|
||||
buffer.push("<span class='badge-posts'>#{reply_count}</span>")
|
||||
@ -97,7 +95,6 @@ window.Discourse.PostMenuView = Ember.View.extend Discourse.Presence,
|
||||
|
||||
clickReply: -> @get('controller').replyToPost(@get('post'))
|
||||
|
||||
|
||||
# Bookmark button
|
||||
renderBookmark: (post, buffer) ->
|
||||
return unless Discourse.get('currentUser')
|
||||
|
@ -29,6 +29,7 @@ class SiteSetting < ActiveRecord::Base
|
||||
client_setting(:min_topic_title_length, 5)
|
||||
client_setting(:max_topic_title_length, 255)
|
||||
client_setting(:flush_timings_secs, 5)
|
||||
client_setting(:supress_reply_directly_below, true)
|
||||
|
||||
# settings only available server side
|
||||
setting(:auto_track_topics_after, 60000)
|
||||
@ -136,6 +137,8 @@ class SiteSetting < ActiveRecord::Base
|
||||
# Ways to catch griefers and other nasties
|
||||
setting(:email_blacklist_regexp, '')
|
||||
|
||||
|
||||
|
||||
def self.call_mothership?
|
||||
self.enforce_global_nicknames? and self.discourse_org_access_key.present?
|
||||
end
|
||||
|
@ -259,7 +259,7 @@ en:
|
||||
posts_per_page: "How many posts are returned on a topic page"
|
||||
system_username: "Username that sends system messages"
|
||||
send_welcome_message: "Do new users get a welcome private message?"
|
||||
|
||||
supress_reply_directly_below: "Don't show replies button below a post when the reply is directly below"
|
||||
allow_index_in_robots_txt: "Site should be indexed by search engines (update robots.txt)"
|
||||
|
||||
port: "If you'd like to specify a port in the URL. Useful in development mode. Leave blank for none."
|
||||
|
Loading…
Reference in New Issue
Block a user