Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCHv5] [issue14] poll updates accumulate while idle
@ 2010-01-15 12:59 Eric Sherman
  2010-02-27  8:07 ` Rich Lane
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Sherman @ 2010-01-15 12:59 UTC (permalink / raw)
  To: sup-devel

If you were to leave sup running for a long time, this patch would
enable you to get a glance summary of new mail activity since sup was
last touched, by letting the poll update message accumulate its tally
while idle.

Oops, forgot to clear_running_totals on :unidle.

This patch depends on [PATCHv2] idle and unidle updates.
---
 lib/sup/poll.rb |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
index f3e1224..6b43b00 100644
--- a/lib/sup/poll.rb
+++ b/lib/sup/poll.rb
@@ -37,6 +37,9 @@ EOS
     @polling = false
     @poll_sources = nil
     @mode = nil
+    @should_clear_running_totals = false
+    clear_running_totals # defines @running_totals
+    UpdateManager.register self
   end
 
   def poll_with_sources
@@ -45,8 +48,12 @@ EOS
 
     BufferManager.flash "Polling for new messages..."
     num, numi, from_and_subj, from_and_subj_inbox, loaded_labels = @mode.poll
-    if num > 0
-      BufferManager.flash "Loaded #{num.pluralize 'new message'}, #{numi} to inbox. Labels: #{loaded_labels.map{|l| l.to_s}.join(', ')}"
+    clear_running_totals if @should_clear_running_totals
+    @running_totals[:num] += num
+    @running_totals[:numi] += numi
+    @running_totals[:loaded_labels] += loaded_labels || []
+    if @running_totals[:num] > 0
+      BufferManager.flash "Loaded #{@running_totals[:num].pluralize 'new message'}, #{@running_totals[:numi]} to inbox. Labels: #{@running_totals[:loaded_labels].map{|l| l.to_s}.join(', ')}"
     else
       BufferManager.flash "No new messages." 
     end
@@ -183,6 +190,10 @@ EOS
     Index.add_message m
     UpdateManager.relay self, :added, m
   end
+
+  def handle_idle_update sender, idle_since; @should_clear_running_totals = false; end
+  def handle_unidle_update sender, idle_since; @should_clear_running_totals = true; clear_running_totals; end
+  def clear_running_totals; @running_totals = {:num => 0, :numi => 0, :loaded_labels => Set.new}; end
 end
 
 end
-- 
1.6.6

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [sup-devel] [PATCHv5] [issue14] poll updates accumulate while idle
  2010-01-15 12:59 [sup-devel] [PATCHv5] [issue14] poll updates accumulate while idle Eric Sherman
@ 2010-02-27  8:07 ` Rich Lane
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Lane @ 2010-02-27  8:07 UTC (permalink / raw)
  To: Eric Sherman; +Cc: sup-devel

Branch idle, merged to next.
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-27  8:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-15 12:59 [sup-devel] [PATCHv5] [issue14] poll updates accumulate while idle Eric Sherman
2010-02-27  8:07 ` Rich Lane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox