Commit 5a54faf2bb95dcf34601f55a8ed4697365a30977

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

Update window when callback is called

Before, if modal was opened, window would not be refresh
Now, it is refreshed
app/assets/javascripts/v_libras/videos/index.js.erb
@@ -7,14 +7,15 @@ $(function() { @@ -7,14 +7,15 @@ $(function() {
7 var channel = dispatcher.subscribe('requests_update'); 7 var channel = dispatcher.subscribe('requests_update');
8 8
9 // bind to a channel event 9 // bind to a channel event
10 - channel.bind('update', function(data) {  
11 - /* alert("Um vídeo que estava em processamento está disponível. Sua página será atualizada automaticamente.") */ 10 + // If video is finished, update window on any case
  11 + channel.bind('callback_called', function(data) {
  12 + window.location = window.location.pathname;
  13 + });
12 14
13 - if ($('#modal-wait').hasClass('in')) {  
14 - $('#modal-wait').on('hidden', function () {  
15 - window.location = window.location.pathname;  
16 - })  
17 - } else { 15 + // The other event will only update the window if #modal-wait is closed
  16 + 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 + if (! $('#modal-wait').hasClass('in')) {
18 window.location = window.location.pathname; 19 window.location = window.location.pathname;
19 } 20 }
20 }); 21 });
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(:update, {}) 17 + WebsocketRails[:requests_update].trigger(:callback_called)
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(:update, {a: :b, c: :d}) 26 + WebsocketRails[:requests_update].trigger(:video_submitted)
27 end 27 end
28 28
29 29