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  64ba040   cosmetic improvements:
64ba040 is described below

commit 64ba040b6e4be84655c44b319014daa4890f4105
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Sun Sep 18 20:37:38 2016 -0400

    cosmetic improvements:
    
    1) reword empty queue message
    2) hide previous month button unless there are messages in that month
---
 www/secmail/views/index.js.rb   |  8 ++++++--
 www/secmail/views/index.json.rb | 11 ++++++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/www/secmail/views/index.js.rb b/www/secmail/views/index.js.rb
index 1cd1c43..6462f3b 100644
--- a/www/secmail/views/index.js.rb
+++ b/www/secmail/views/index.js.rb
@@ -7,11 +7,12 @@ class Index < React
     @selected = nil
     @messages = []
     @checking = false
+    @fetched = false
   end
 
   def render
     if not @messages or @messages.all? {|message| message.status == :deleted}
-      _p 'No documents remain to be processed.'
+      _p 'All documents have been processed.'
     else
       _table do
        _thead do
@@ -45,7 +46,7 @@ class Index < React
       end
     end
 
-    if @nextmbox
+    if @fetched and @nextmbox
       _button.btn.btn_primary 'download previous month',
         onClick: self.fetch_month
     end
@@ -113,6 +114,9 @@ class Index < React
   # fetch a month's worth of messages
   def fetch_month(&block)
     HTTP.get(@nextmbox, :json).then {|response|
+      # indicate that (at least one) fetch is complete
+      @fetched = true
+
       # update latest mbox
       @nextmbox = response.mbox
 
diff --git a/www/secmail/views/index.json.rb b/www/secmail/views/index.json.rb
index 82c6ed5..54c1d06 100644
--- a/www/secmail/views/index.json.rb
+++ b/www/secmail/views/index.json.rb
@@ -4,9 +4,18 @@ index = available.find_index "#{ARCHIVE}/#{@mbox}.yml"
 
 # if found, process it
 if index
+  prevmbox = nil
+
+  if index > 0
+    prevmbox = available[index-1].untaint
+    prevmbox = nil unless YAML.load_file(prevmbox).any? do |key, mail| 
+      mail[:status] != :deleted and mail[:attachments]
+    end
+  end
+
   # return previous mailbox name and headers for the messages in the mbox
   {
-    mbox: (File.basename(available[index-1].untaint, '.yml') if index > 0),
+    mbox: (File.basename(prevmbox, '.yml') if prevmbox),
     messages: Mailbox.new(@mbox).client_headers
   }
 end

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

Reply via email to