whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: decouple service workers from events
Date Sun, 16 Oct 2016 16:01:09 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  72f6175   decouple service workers from events
72f6175 is described below

commit 72f61753d38f85508e8d1a44eda5db4402b286c5
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Sun Oct 16 12:00:40 2016 -0400

    decouple service workers from events
---
 www/board/agenda/views/layout/main.js.rb      | 12 +++++-----
 www/board/agenda/views/models/pagecache.js.rb | 32 ---------------------------
 2 files changed, 5 insertions(+), 39 deletions(-)

diff --git a/www/board/agenda/views/layout/main.js.rb b/www/board/agenda/views/layout/main.js.rb
index 0a593b7..70f6385 100644
--- a/www/board/agenda/views/layout/main.js.rb
+++ b/www/board/agenda/views/layout/main.js.rb
@@ -152,14 +152,12 @@ class Main < React
     # if agenda is stale, fetch immediately; otherwise save etag
     Agenda.fetch(@@page.etag, @@page.digest)
 
+    # start Service Worker
+    console.log 'starting'
+    PageCache.register() if PageCache.enabled
+  
     # start backchannel
-    if PageCache.enabled
-      # use Service Workers
-      PageCache.register()
-    else
-      # use localStorage
-      Events.monitor()
-    end
+    Events.monitor()
   end
 
   # after each subsequent re-rendering, resize main window
diff --git a/www/board/agenda/views/models/pagecache.js.rb b/www/board/agenda/views/models/pagecache.js.rb
index ad4f98d..32f21a4 100644
--- a/www/board/agenda/views/models/pagecache.js.rb
+++ b/www/board/agenda/views/models/pagecache.js.rb
@@ -34,11 +34,6 @@ class PageCache
     # register service worker
     scope = URL.new('..', document.getElementsByTagName('base')[0].href)
     navigator.serviceWorker.register(scope + 'sw.js', scope)
-
-    # forward service worker events
-    navigator.serviceWorker.addEventListener :message do |event|
-      Events.dispatch event.data
-    end
   end
 
   # aggressively attempt to preload pages directly used by the agenda pages
@@ -53,33 +48,6 @@ class PageCache
       caches.open('board/agenda').then do |cache|
         cache.put(request, response.clone())
       end
-
-      # update browser cache with latest scripts and stylesheets.
-      response.text().then do |text|
-        urls = []
-
-        # search body text for scripts
-        script = Regexp.new(/<script.*?>/, 'g')
-        matches = text.match(script)
-        matches.each do |match|
-          src = match.match(/src="(.*?)"/)
-          urls << URL.new(src[1], base) if src
-        end
-
-        # search body text for links to stylesheets
-        links = Regexp.new(/<link.*?>/, 'g')
-        matches = text.match(links)
-        matches.each do |match|
-          href = match.match(/href="(.*?)"/)
-          urls << URL.new(href[1], base) if href
-        end
-
-        # Fetch each URL.  Note: no network requests will be made if these
-        # pages are up to date
-        urls.each do |url|
-          fetch(Request.new(url, credentials: 'include'))
-        end
-      end
     end
   end
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message