Commit 3259d858d259f6964548804ebc36d1c7991da92a

Authored by Fernando Brito
1 parent c8b85c37
Exists in master and in 2 other branches v2, wikilibras

Filter callback refresh within user context

app/assets/javascripts/v_libras/videos/index.js.erb
... ... @@ -9,14 +9,17 @@ $(function() {
9 9 // bind to a channel event
10 10 // If video is finished, update window on any case
11 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 16 // The other event will only update the window if #modal-wait is closed
16 17 channel.bind('video_submitted', function(data) {
17 18 /* alert("Um vídeo que estava em processamento está disponível. Sua página será atualizada automaticamente.") */
  19 +
18 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 26 \ No newline at end of file
... ...
app/views/v_libras/videos/index.haml
... ... @@ -68,6 +68,8 @@
68 68  
69 69 - content_for :javascript_code do
70 70 :javascript
  71 + current_user = #{current_user.id};
  72 +
71 73 $(function () {
72 74 $('#modal-wait').modal();
73 75 })
74 76 \ No newline at end of file
... ...
lib/api_client/callback_processor.rb
... ... @@ -14,6 +14,6 @@ class ApiClient::CallbackProcessor
14 14 end
15 15  
16 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 18 end
19 19 end
20 20 \ No newline at end of file
... ...
lib/api_client/client.rb
... ... @@ -23,7 +23,7 @@ module ApiClient::Client
23 23 ensure
24 24 # FIXME: Running on another thread. Websocket not working :(
25 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 27 end
28 28  
29 29  
... ...