You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2017/12/04 14:18:55 UTC
[whimsy] branch master updated: check for updates whenever the
server is reconnected
This is an automated email from the ASF dual-hosted git repository.
rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 1881928 check for updates whenever the server is reconnected
1881928 is described below
commit 18819280d67392c9461c714c8b1362310383d6e1
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Mon Dec 4 09:18:37 2017 -0500
check for updates whenever the server is reconnected
---
www/board/agenda/views/models/events.js.rb | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/www/board/agenda/views/models/events.js.rb b/www/board/agenda/views/models/events.js.rb
index bd5e5ad..5430e12 100644
--- a/www/board/agenda/views/models/events.js.rb
+++ b/www/board/agenda/views/models/events.js.rb
@@ -113,14 +113,14 @@ class Events
# master logic
def self.master()
- self.connectToServer()
+ self.connectToServer(false)
# proof of life; maintain connection to the server
setInterval 25_000 do
localStorage.setItem("#{@@prefix}-timestamp", Date.new().getTime())
if not Server.offline
- self.connectToServer()
+ self.connectToServer(true)
elsif @@socket
@@socket.close()
end
@@ -130,17 +130,7 @@ class Events
if event.detail == true
@@socket.close() if @@socket
else
- self.connectToServer()
-
- # see if the agenda changed
- fetch('digest.json', credentials: 'include').then do |response|
- if response.ok
- response.json().then do |json|
- json.type = :agenda
- Events.broadcast json
- end
- end
- end
+ self.connectToServer(true)
end
end
@@ -151,7 +141,7 @@ class Events
end
# establish a connection to the server
- def self.connectToServer()
+ def self.connectToServer(check_for_updates)
return if @@socket
socket_url = window.location.protocol.sub('http', 'ws') + "//" +
@@ -162,6 +152,18 @@ class Events
def @@socket.onopen(event)
@@socket.send "session: #{Server.session}\n\n"
self.log 'WebSocket connection established'
+
+ if check_for_updates
+ # see if the agenda changed
+ fetch('digest.json', credentials: 'include').then do |response|
+ if response.ok
+ response.json().then do |json|
+ json.type = :agenda
+ Events.broadcast json
+ end
+ end
+ end
+ end
end
def @@socket.onmessage(event)
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].