Commit 0966e8bd by Ibrahim Awwal

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.
parent 6315fe3f
......@@ -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()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment