Sorting should keep trace of comment and like updates.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user