mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 14:23:39 +08:00
Remove the distinction between "x replies below" and "x replies"
This commit is contained in:
parent
12d3c3b66b
commit
25e9cfe3b8
|
@ -277,15 +277,7 @@ window.Discourse.Composer = Discourse.Model.extend
|
||||||
# If we're in a topic, we can append the post instantly.
|
# If we're in a topic, we can append the post instantly.
|
||||||
if topic
|
if topic
|
||||||
# Increase the reply count
|
# Increase the reply count
|
||||||
if post
|
post?.set('reply_count', (post.get('reply_count') || 0) + 1)
|
||||||
post.set('reply_count', (post.get('reply_count') || 0) + 1)
|
|
||||||
|
|
||||||
# Supress replies
|
|
||||||
if (post.get('reply_count') == 1 && createdPost.get('cooked').length < Discourse.SiteSettings.max_length_show_reply)
|
|
||||||
post.set('replyFollowing', true)
|
|
||||||
|
|
||||||
post.set('reply_below_post_number', createdPost.get('post_number'))
|
|
||||||
|
|
||||||
topic.set('posts_count', topic.get('posts_count') + 1)
|
topic.set('posts_count', topic.get('posts_count') + 1)
|
||||||
|
|
||||||
# Update last post
|
# Update last post
|
||||||
|
|
|
@ -21,27 +21,6 @@ window.Discourse.Post = Ember.Object.extend Discourse.Presence,
|
||||||
hasHistory: (-> @get('version') > 1 ).property('version')
|
hasHistory: (-> @get('version') > 1 ).property('version')
|
||||||
postElementId: (-> "post_#{@get('post_number')}").property()
|
postElementId: (-> "post_#{@get('post_number')}").property()
|
||||||
|
|
||||||
# We only want to link to replies below if there's exactly one reply and it's below
|
|
||||||
replyBelowUrlComputed: (->
|
|
||||||
|
|
||||||
return null unless @get('reply_below_post_number')
|
|
||||||
return null if @get('reply_count') > 1
|
|
||||||
|
|
||||||
topic = @get('topic')
|
|
||||||
return unless topic
|
|
||||||
|
|
||||||
p = @get('reply_below_post_number')
|
|
||||||
diff = @get('reply_below_post_number') - @get('post_number')
|
|
||||||
return topic.urlForPostNumber(p) if (diff < 3)
|
|
||||||
null
|
|
||||||
).property('topic', 'reply_below_post_number')
|
|
||||||
|
|
||||||
# We do this because right now you can't subclass a computed property and we want to add
|
|
||||||
# plugin support. Later we should consider just subclassing it properly.
|
|
||||||
replyBelowUrl: (->
|
|
||||||
@get('replyBelowUrlComputed')
|
|
||||||
).property('replyBelowUrlComputed')
|
|
||||||
|
|
||||||
# The class for the read icon of the post. It starts with read-icon then adds 'seen' or
|
# The class for the read icon of the post. It starts with read-icon then adds 'seen' or
|
||||||
# 'last-read' if the post has been seen or is the highest post number seen so far respectively.
|
# 'last-read' if the post has been seen or is the highest post number seen so far respectively.
|
||||||
bookmarkClass: (->
|
bookmarkClass: (->
|
||||||
|
|
|
@ -206,11 +206,6 @@ Discourse.Topic = Discourse.Model.extend Discourse.Presence,
|
||||||
# when there
|
# when there
|
||||||
lastPost = null
|
lastPost = null
|
||||||
result.posts.each (p) =>
|
result.posts.each (p) =>
|
||||||
|
|
||||||
# Determine whether there is a short reply below
|
|
||||||
if (lastPost && lastPost.get('reply_count') == 1) && (p.reply_to_post_number == lastPost.get('post_number')) && (p.cooked.length < Discourse.SiteSettings.max_length_show_reply)
|
|
||||||
lastPost.set('replyFollowing', true)
|
|
||||||
|
|
||||||
p.scrollToAfterInsert = opts.nearPost
|
p.scrollToAfterInsert = opts.nearPost
|
||||||
post = Discourse.Post.create(p)
|
post = Discourse.Post.create(p)
|
||||||
post.set('topic', @)
|
post.set('topic', @)
|
||||||
|
|
|
@ -26,7 +26,7 @@ window.Discourse.PostMenuView = Ember.View.extend Discourse.Presence,
|
||||||
# Trigger re rendering
|
# Trigger re rendering
|
||||||
needsToRender: (->
|
needsToRender: (->
|
||||||
@rerender()
|
@rerender()
|
||||||
).observes('post.deleted_at', 'post.flagsAvailable.@each', 'post.url', 'post.bookmarked', 'post.reply_count', 'post.replyBelowUrl', 'post.can_delete')
|
).observes('post.deleted_at', 'post.flagsAvailable.@each', 'post.url', 'post.bookmarked', 'post.reply_count', 'post.can_delete')
|
||||||
|
|
||||||
# Replies Button
|
# Replies Button
|
||||||
renderReplies: (post, buffer) ->
|
renderReplies: (post, buffer) ->
|
||||||
|
@ -39,8 +39,7 @@ window.Discourse.PostMenuView = Ember.View.extend Discourse.Presence,
|
||||||
buffer.push("<button class='show-replies' data-action='replies'>")
|
buffer.push("<button class='show-replies' data-action='replies'>")
|
||||||
buffer.push("<span class='badge-posts'>#{reply_count}</span>")
|
buffer.push("<span class='badge-posts'>#{reply_count}</span>")
|
||||||
|
|
||||||
textKey = if post.get('replyBelowUrl') then "post.has_replies" else "post.has_replies_below"
|
buffer.push(Em.String.i18n("post.has_replies", count: reply_count))
|
||||||
buffer.push(Em.String.i18n(textKey, count: reply_count))
|
|
||||||
|
|
||||||
icon = if @get('postView.repliesShown') then 'icon-chevron-up' else 'icon-chevron-down'
|
icon = if @get('postView.repliesShown') then 'icon-chevron-up' else 'icon-chevron-down'
|
||||||
buffer.push("<i class='icon #{icon}'></i></button>")
|
buffer.push("<i class='icon #{icon}'></i></button>")
|
||||||
|
|
|
@ -73,12 +73,6 @@ window.Discourse.PostView = Ember.View.extend
|
||||||
|
|
||||||
# Click on the replies button
|
# Click on the replies button
|
||||||
showReplies: ->
|
showReplies: ->
|
||||||
|
|
||||||
# If the reply is below, we route to it
|
|
||||||
if replyBelowUrl = @get('post.replyBelowUrl')
|
|
||||||
Discourse.routeTo(replyBelowUrl)
|
|
||||||
return false
|
|
||||||
|
|
||||||
if @get('repliesShown')
|
if @get('repliesShown')
|
||||||
@set('repliesShown', false)
|
@set('repliesShown', false)
|
||||||
else
|
else
|
||||||
|
|
|
@ -473,8 +473,7 @@ class Post < ActiveRecord::Base
|
||||||
if post.present?
|
if post.present?
|
||||||
post_reply = post.post_replies.new(reply_id: self.id)
|
post_reply = post.post_replies.new(reply_id: self.id)
|
||||||
if post_reply.save
|
if post_reply.save
|
||||||
Post.update_all ['reply_count = reply_count + 1, reply_below_post_number = COALESCE(reply_below_post_number, ?)', self.post_number],
|
Post.update_all ['reply_count = reply_count + 1'], id: post.id
|
||||||
["id = ?", post.id]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,6 @@ class PostSerializer < ApplicationSerializer
|
||||||
:updated_at,
|
:updated_at,
|
||||||
:reply_count,
|
:reply_count,
|
||||||
:reply_to_post_number,
|
:reply_to_post_number,
|
||||||
:reply_below_post_number,
|
|
||||||
:quote_count,
|
:quote_count,
|
||||||
:avg_time,
|
:avg_time,
|
||||||
:incoming_link_count,
|
:incoming_link_count,
|
||||||
|
|
|
@ -778,7 +778,6 @@ en:
|
||||||
reply:
|
reply:
|
||||||
title: 'Reply'
|
title: 'Reply'
|
||||||
help: 'begin composing a reply to this topic'
|
help: 'begin composing a reply to this topic'
|
||||||
below: 'reply below'
|
|
||||||
|
|
||||||
share:
|
share:
|
||||||
title: 'Share'
|
title: 'Share'
|
||||||
|
@ -837,10 +836,6 @@ en:
|
||||||
follow_quote: "go to the quoted post"
|
follow_quote: "go to the quoted post"
|
||||||
deleted_by_author: "(post removed by author)"
|
deleted_by_author: "(post removed by author)"
|
||||||
|
|
||||||
has_replies_below:
|
|
||||||
one: "Reply Below"
|
|
||||||
other: "Replies Below"
|
|
||||||
|
|
||||||
has_replies:
|
has_replies:
|
||||||
one: "Reply"
|
one: "Reply"
|
||||||
other: "Replies"
|
other: "Replies"
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class RemoveReplyBelowPostNumberFromPosts < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
remove_column :posts, :reply_below_post_number
|
||||||
|
end
|
||||||
|
end
|
2045
db/structure.sql
2045
db/structure.sql
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user