Commit 3259d858d259f6964548804ebc36d1c7991da92a
1 parent
c8b85c37
Exists in
master
and in
2 other branches
Filter callback refresh within user context
Showing
4 changed files
with
9 additions
and
4 deletions
Show diff stats
app/assets/javascripts/v_libras/videos/index.js.erb
@@ -9,14 +9,17 @@ $(function() { | @@ -9,14 +9,17 @@ $(function() { | ||
9 | // bind to a channel event | 9 | // bind to a channel event |
10 | // If video is finished, update window on any case | 10 | // If video is finished, update window on any case |
11 | channel.bind('callback_called', function(data) { | 11 | channel.bind('callback_called', function(data) { |
12 | - window.location = window.location.pathname; | 12 | + if (data.owner_id === current_user) |
13 | + window.location = window.location.pathname; | ||
13 | }); | 14 | }); |
14 | 15 | ||
15 | // The other event will only update the window if #modal-wait is closed | 16 | // The other event will only update the window if #modal-wait is closed |
16 | channel.bind('video_submitted', function(data) { | 17 | channel.bind('video_submitted', function(data) { |
17 | /* alert("Um vídeo que estava em processamento está disponível. Sua página será atualizada automaticamente.") */ | 18 | /* alert("Um vídeo que estava em processamento está disponível. Sua página será atualizada automaticamente.") */ |
19 | + | ||
18 | if (! $('#modal-wait').hasClass('in')) { | 20 | if (! $('#modal-wait').hasClass('in')) { |
19 | - window.location = window.location.pathname; | 21 | + if (data.owner_id === current_user) |
22 | + window.location = window.location.pathname; | ||
20 | } | 23 | } |
21 | }); | 24 | }); |
22 | }); | 25 | }); |
23 | \ No newline at end of file | 26 | \ No newline at end of file |
app/views/v_libras/videos/index.haml
@@ -68,6 +68,8 @@ | @@ -68,6 +68,8 @@ | ||
68 | 68 | ||
69 | - content_for :javascript_code do | 69 | - content_for :javascript_code do |
70 | :javascript | 70 | :javascript |
71 | + current_user = #{current_user.id}; | ||
72 | + | ||
71 | $(function () { | 73 | $(function () { |
72 | $('#modal-wait').modal(); | 74 | $('#modal-wait').modal(); |
73 | }) | 75 | }) |
74 | \ No newline at end of file | 76 | \ No newline at end of file |
lib/api_client/callback_processor.rb
@@ -14,6 +14,6 @@ class ApiClient::CallbackProcessor | @@ -14,6 +14,6 @@ class ApiClient::CallbackProcessor | ||
14 | end | 14 | end |
15 | 15 | ||
16 | Rails.logger.debug "[VLibras::Callback] Notifying websocket channel" | 16 | Rails.logger.debug "[VLibras::Callback] Notifying websocket channel" |
17 | - WebsocketRails[:requests_update].trigger(:callback_called) | 17 | + WebsocketRails[:requests_update].trigger(:callback_called, { :owner_id => request.owner_id }) |
18 | end | 18 | end |
19 | end | 19 | end |
20 | \ No newline at end of file | 20 | \ No newline at end of file |
lib/api_client/client.rb
@@ -23,7 +23,7 @@ module ApiClient::Client | @@ -23,7 +23,7 @@ module ApiClient::Client | ||
23 | ensure | 23 | ensure |
24 | # FIXME: Running on another thread. Websocket not working :( | 24 | # FIXME: Running on another thread. Websocket not working :( |
25 | Delayed::Worker.logger.debug "[VLibras::Request] Sending message to websocket channel" | 25 | Delayed::Worker.logger.debug "[VLibras::Request] Sending message to websocket channel" |
26 | - WebsocketRails[:requests_update].trigger(:video_submitted) | 26 | + WebsocketRails[:requests_update].trigger(:video_submitted, { :owner_id => request.owner_id }) |
27 | end | 27 | end |
28 | 28 | ||
29 | 29 |