Commit 41b669d6 by Matthew Mongeau

Show current following status in list view.

parent 7f67fc5a
......@@ -421,6 +421,12 @@ if Backbone?
@set('thread', @)
super()
follow: ->
@trigger "thread:follow"
unfollow: ->
@trigger "thread:unfollow"
class @ThreadView extends @ContentView
class @Comment extends @Content
......
......@@ -44,8 +44,10 @@ class @DiscussionThreadView extends Backbone.View
@$(".dogear").toggleClass("is-followed")
url = null
if @$(".dogear").hasClass("is-followed")
@model.follow()
url = @model.urlFor("follow")
else
@model.unfollow()
url = @model.urlFor("unfollow")
DiscussionUtil.safeAjax
$elem: $elem
......
......@@ -5,11 +5,17 @@ class @ThreadListItemView extends Backbone.View
"click a": "threadSelected"
initialize: ->
@model.on "change", @render
@model.on "thread:follow", @follow
@model.on "thread:unfollow", @unfollow
render: =>
@$el.html(@template(@model.toJSON()))
if window.user.following(@model)
@$("a").addClass("followed")
@follow()
@
threadSelected: ->
@trigger("thread:selected", @model.id)
false
follow: =>
@$("a").addClass("followed")
unfollow: =>
@$("a").removeClass("followed")
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