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 5d77c2b  Make clock_counter reactive
5d77c2b is described below

commit 5d77c2ba899dc21e62114a9c9b0508c0cff0ca29
Author: Sam Ruby <[email protected]>
AuthorDate: Thu Sep 28 19:10:12 2017 -0400

    Make clock_counter reactive
---
 www/board/agenda/README.md                      |  3 +--
 www/board/agenda/views/keyboard.js.rb           |  4 ++--
 www/board/agenda/views/layout/header.js.rb      | 17 +++--------------
 www/board/agenda/views/models/jsonstorage.js.rb |  6 +++---
 www/board/agenda/views/utils.js.rb              |  9 ++-------
 5 files changed, 11 insertions(+), 28 deletions(-)

diff --git a/www/board/agenda/README.md b/www/board/agenda/README.md
index 3325165..b1e22bb 100644
--- a/www/board/agenda/README.md
+++ b/www/board/agenda/README.md
@@ -139,8 +139,7 @@ At this point, you have something up and running.  Let's 
take a look around.
    underscore.  Methods and computed properties will not be.
 
  * If you are so inclined, you can actually make changes to the
-   datastructures.  Those changes won't be visible until you re-render.
-   Something to try: `Main.item._report = 'All is Good!'; Main.refresh()`
+   datastructures.  Something to try: `Main.item._report = 'All is Good!'`
 
  * One last thing before we leave this section, go to an agenda page, and
    replace the final `/` in the URL with `.json`.  The contents you see is
diff --git a/www/board/agenda/views/keyboard.js.rb 
b/www/board/agenda/views/keyboard.js.rb
index a3ffb80..2ada088 100644
--- a/www/board/agenda/views/keyboard.js.rb
+++ b/www/board/agenda/views/keyboard.js.rb
@@ -79,10 +79,10 @@ class Keyboard
         Main.navigate "help"
         return false
       elsif event.keyCode == 'R'.ord
-        clock_counter += 1
+        Header.clock_counter += 1
         Main.refresh()
         post 'refresh', agenda: Agenda.file do |response|
-          clock_counter -= 1
+          Header.clock_counter -= 1
           Agenda.load response.agenda, response.digest
           Main.refresh()
         end
diff --git a/www/board/agenda/views/layout/header.js.rb 
b/www/board/agenda/views/layout/header.js.rb
index 7839466..73f5ddf 100644
--- a/www/board/agenda/views/layout/header.js.rb
+++ b/www/board/agenda/views/layout/header.js.rb
@@ -6,9 +6,10 @@
 # Finally: make info dropdown status 'sticky'
 
 class Header < Vue
+  Header.clock_counter = 0
+
   def initialize
     @infodropdown = nil
-    @clock_counter = 0
   end
 
   def render
@@ -19,7 +20,7 @@ class Header < Vue
         _PodlingNameSearch item: @@item
       end
 
-      _span.clock! "\u231B" if @clock_counter > 0
+      _span.clock! "\u231B" if Header.clock_counter > 0
 
       _ul.nav.nav_pills.navbar_right do
 
@@ -127,18 +128,6 @@ class Header < Vue
     end
   end
 
-  def beforeMount()
-    EventBus.on :clock_counter, self.update_counter
-  end
-
-  def beforeDestroy()
-    EventBus.off :clock_counter, self.update_counter
-  end
-
-  def update_counter(counter)
-    @clock_counter = counter
-  end
-
   # toggle info dropdown
   def toggleInfo()
     @infodropdown = (@infodropdown ? nil : 'open')
diff --git a/www/board/agenda/views/models/jsonstorage.js.rb 
b/www/board/agenda/views/models/jsonstorage.js.rb
index 3935adb..bb63e9e 100644
--- a/www/board/agenda/views/models/jsonstorage.js.rb
+++ b/www/board/agenda/views/models/jsonstorage.js.rb
@@ -52,7 +52,7 @@ class JSONStorage
     then
       caches.open('board/agenda').then do |cache|
         fetched = nil
-        clock_counter += 1
+        Header.clock_counter += 1
 
         # construct request
         request = Request.new("../json/#{name}", method: 'get',
@@ -64,7 +64,7 @@ class JSONStorage
 
           response.json().then do |json| 
             unless fetched and fetched.inspect == json.inspect
-              clock_counter -= 1 unless fetched
+              Header.clock_counter -= 1 unless fetched
               fetched = json
               block(json) if json
               Main.refresh()
@@ -76,7 +76,7 @@ class JSONStorage
         cache.match("../json/#{name}").then do |response|
           if response and not fetched
             response.json().then do |json| 
-              clock_counter -= 1
+              Header.clock_counter -= 1
               fetched = json
               block(json) if json
               Main.refresh()
diff --git a/www/board/agenda/views/utils.js.rb 
b/www/board/agenda/views/utils.js.rb
index f31f9d2..137620a 100644
--- a/www/board/agenda/views/utils.js.rb
+++ b/www/board/agenda/views/utils.js.rb
@@ -1,9 +1,6 @@
 # A convenient place to stash server data
 Server = {}
 
-# controls display of clock in the header
-clock_counter = 0
-
 #
 # function to assist with production of HTML and regular expressions
 #
@@ -88,8 +85,7 @@ def retrieve(target, type, &block)
 
   def xhr.onreadystatechange()
     if xhr.readyState == 1
-      clock_counter += 1
-      EventBus.emit :clock_counter, clock_counter
+      Header.clock_counter += 1
     elsif xhr.readyState == 4
       data = nil
 
@@ -119,8 +115,7 @@ def retrieve(target, type, &block)
       end
 
       block(data)
-      clock_counter -= 1
-      EventBus.emit :clock_counter, clock_counter
+      Header.clock_counter -= 1
     end
   end
 

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to