Commit 4feb8327 by kimth

Polling rerenders problem when individual queued items return

parent 6c29b424
...@@ -32,7 +32,8 @@ class @Problem ...@@ -32,7 +32,8 @@ class @Problem
queueing: => queueing: =>
@queued_items = @$(".xqueue") @queued_items = @$(".xqueue")
if @queued_items.length > 0 @num_queued_items = @queued_items.length
if @num_queued_items > 0
if window.queuePollerID # Only one poller 'thread' per Problem if window.queuePollerID # Only one poller 'thread' per Problem
window.clearTimeout(window.queuePollerID) window.clearTimeout(window.queuePollerID)
queuelen = @get_queuelen() queuelen = @get_queuelen()
...@@ -49,12 +50,16 @@ class @Problem ...@@ -49,12 +50,16 @@ class @Problem
poll: => poll: =>
$.postWithPrefix "#{@url}/problem_get", (response) => $.postWithPrefix "#{@url}/problem_get", (response) =>
@queued_items = $(response.html).find(".xqueue") # If queueing status changed, then render
if @queued_items.length == 0 @new_queued_items = $(response.html).find(".xqueue")
if @new_queued_items.length isnt @num_queued_items
@el.html(response.html) @el.html(response.html)
@executeProblemScripts () => @executeProblemScripts () =>
@setupInputTypes() @setupInputTypes()
@bind() @bind()
@num_queued_items = @new_queued_items.length
if @num_queued_items == 0
delete window.queuePollerID delete window.queuePollerID
else else
# TODO: Some logic to dynamically adjust polling rate based on queuelen # TODO: Some logic to dynamically adjust polling rate based on queuelen
......
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