Commit af04f5a3 by Kevin Chugh

got flagging to work

parent 033ed6ce
......@@ -117,11 +117,13 @@ if Backbone?
@trigger "change", @
flagAbuse: ->
@get("abuse_flaggers").push window.user.get('id')
temp_array = @get("abuse_flaggers")
temp_array.push(window.user.get('id'))
@set("abuse_flaggers",temp_array)
@trigger "change", @
unflagAbuse: ->
@get("abuse_flaggers").pop window.user.get('id')
@get("abuse_flaggers").pop(window.user.get('id'))
@trigger "change", @
display_body: ->
......
......@@ -110,7 +110,13 @@ if Backbone?
type: "POST"
success: (response, textStatus) =>
if textStatus == 'success'
@model.set(response, {silent: true})
###
note, we have to clone the array in order to trigger a change event
that's 5 hours of my life i'll never get back.
###
temp_array = _.clone(@model.get('abuse_flaggers'));
temp_array.push(window.user.id)
@model.set('abuse_flaggers', temp_array)
unvote: ->
window.user.unvote(@model)
......@@ -131,7 +137,9 @@ if Backbone?
type: "POST"
success: (response, textStatus) =>
if textStatus == 'success'
@model.set(response, {silent: true})
temp_array = _.clone(@model.get('abuse_flaggers'));
temp_array.pop(window.user.id)
@model.set('abuse_flaggers', temp_array)
edit: (event) ->
@trigger "thread:edit", event
......
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