Commit 9da7a337 by Matthew Mongeau

Sorting should keep trace of comment and like updates.

parent 2380e7ff
......@@ -439,6 +439,9 @@ if Backbone?
@set('thread', @)
super()
comment: ->
@set("comments_count", parseInt(@get("comments_count")) + 1)
follow: ->
@set('subscribed', true)
@trigger "thread:follow"
......
......@@ -10,6 +10,11 @@ class @DiscussionThreadListView extends Backbone.View
initialize: ->
@displayedCollection = new Discussion(@collection.models)
@collection.on "change", @reloadDisplayedCollection
reloadDisplayedCollection: =>
@displayedCollection.reset(@collection.models)
# Because we want the behavior that when the body is clicked the menu is
# closed, we need to ignore clicks in the search field and stop propagation.
......@@ -96,10 +101,6 @@ class @DiscussionThreadListView extends Backbone.View
@displayedCollection.comparator = @displayedCollection.sortByComments
@displayedCollection.sort()
delay: (callback, ms) =>
clearTimeout(@timer)
@timer = setTimeout(callback, ms)
performSearch: (event) ->
if event.which == 13
event.preventDefault()
......
......@@ -62,7 +62,7 @@ class @DiscussionThreadView extends DiscussionContentView
@$(".responses").append(view.el)
addComment: =>
@model.trigger "comment:add"
@model.comment()
toggleVote: (event) ->
event.preventDefault()
......
class @ThreadListItemView extends Backbone.View
tagName: "li"
template: _.template($("#thread-list-item-template").html())
events:
"click a": "threadSelected"
initialize: ->
@model.on "change", @render
@model.on "thread:follow", @follow
@model.on "thread:unfollow", @unfollow
@model.on "comment:add", @addComment
render: =>
@$el.html(@template(@model.toJSON()))
if window.user.following(@model)
......
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