Keep thread sorting order stable when sorting by comments or votes by using
created_at time as a tiebreaker. This is a stopgap though; the service should handle this. But it looks silly with things shuffling around right now.
This commit is contained in:
@@ -129,6 +129,12 @@ if Backbone?
|
||||
json_attributes = _.clone(@attributes)
|
||||
_.extend(json_attributes, { title: @display_title(), body: @display_body() })
|
||||
|
||||
created_at_date: ->
|
||||
new Date(@get("created_at"))
|
||||
|
||||
created_at_time: ->
|
||||
new Date(@get("created_at")).getTime()
|
||||
|
||||
class @Comment extends @Content
|
||||
urlMappers:
|
||||
'reply': -> DiscussionUtil.urlFor('create_sub_comment', @id)
|
||||
|
||||
@@ -66,9 +66,15 @@ if Backbone?
|
||||
sortByVotes: (thread1, thread2) ->
|
||||
thread1_count = parseInt(thread1.get("votes")['up_count'])
|
||||
thread2_count = parseInt(thread2.get("votes")['up_count'])
|
||||
thread2_count - thread1_count
|
||||
if thread2_count != thread1_count
|
||||
thread2_count - thread1_count
|
||||
else
|
||||
thread2.created_at_time() - thread1.created_at_time()
|
||||
|
||||
sortByComments: (thread1, thread2) ->
|
||||
thread1_count = parseInt(thread1.get("comments_count"))
|
||||
thread2_count = parseInt(thread2.get("comments_count"))
|
||||
thread2_count - thread1_count
|
||||
if thread2_count != thread1_count
|
||||
thread2_count - thread1_count
|
||||
else
|
||||
thread2.created_at_time() - thread1.created_at_time()
|
||||
|
||||
Reference in New Issue
Block a user