From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.213.7.146 with SMTP id d18cs225977ebd; Fri, 15 Jan 2010 04:59:50 -0800 (PST) Received: by 10.224.16.71 with SMTP id n7mr2138978qaa.162.1263560389535; Fri, 15 Jan 2010 04:59:49 -0800 (PST) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id 4si4754693qwe.25.2010.01.15.04.59.49; Fri, 15 Jan 2010 04:59:49 -0800 (PST) Received-SPF: pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-devel-bounces@rubyforge.org; dkim=neutral (body hash did not verify) header.i=@gmail.com Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id E6595167830B; Fri, 15 Jan 2010 07:59:48 -0500 (EST) Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.27]) by rubyforge.org (Postfix) with ESMTP id 2166D15B8029 for ; Fri, 15 Jan 2010 07:59:44 -0500 (EST) Received: by qw-out-2122.google.com with SMTP id 5so114060qwi.29 for ; Fri, 15 Jan 2010 04:59:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:content-type:subject:from:to :date:message-id:user-agent:content-transfer-encoding; bh=un8qLJXdUsQHEhLBJsPC7v9NchxSnjPw8eIof2jPFnc=; b=YNZzlFHOTMmGCkHiSGrVIcQxtjN/U0M6tGLZdevSCNhZ3AORy9NNYIMJHiKo2uASb6 d4YyWO9SKFbOjL7a5gHr89NU+OCx/hfjL9CMOt5TiWQQdTDP4Li30ExfgPGu2gbKgMtO KPL1KKpQqoBNiqN/Zg6fFDLQgNqwUnEQovTXs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:subject:from:to:date:message-id:user-agent :content-transfer-encoding; b=jeA+eZdVAsnumHVyfmtJ8EM4UXAhZY1HVSfxRApOIQenqxCkGIt+yF8fJEra19q0vY gpG7BgkaJKak7w/+5QLMt1KHzUuc5cJndXEOF130uuVCZ9jElpF6wgN/dK/mQorMV/ZT l3c1QiAJ4k0FIA/DwO5Vh75Z/GhivCNvQBg34= Received: by 10.229.68.7 with SMTP id t7mr2010158qci.6.1263560383696; Fri, 15 Jan 2010 04:59:43 -0800 (PST) Received: from localhost (c-76-98-110-216.hsd1.nj.comcast.net [76.98.110.216]) by mx.google.com with ESMTPS id 23sm1658104qyk.7.2010.01.15.04.59.42 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 15 Jan 2010 04:59:43 -0800 (PST) From: Eric Sherman To: sup-devel Date: Fri, 15 Jan 2010 07:59:41 -0500 Message-Id: <1263560293-sup-9529@changeling.local> User-Agent: Sup/git Subject: [sup-devel] [PATCHv5] [issue14] poll updates accumulate while idle X-BeenThere: sup-devel@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Sup developer discussion List-Id: Sup developer discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-devel-bounces@rubyforge.org Errors-To: sup-devel-bounces@rubyforge.org 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