Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: Christopher Bertels <mailinglist@flasht.de>
To: sup-talk <sup-talk@rubyforge.org>
Subject: [sup-talk] show labels of polled messages
Date: Sat, 10 Oct 2009 16:41:29 +0200	[thread overview]
Message-ID: <1255184817-sup-1561@thinkpad-ubuntu> (raw)


[-- Attachment #1.1.1: Type: text/plain, Size: 747 bytes --]

Hi,

I always thought it would be nice to see to which labels new polled
messages have been added. Usually, when I see new messages arrived,
most of them aren't in my inbox, since I archive the messages of most
of my sources (e.g. mailinglists like this one).

Then, I usually go and look at the labels-list-mode to see where new
messages got added. I've attached a patch that displays the labels of
newly polled messages at the bottom, next to the amount of total
messages added from polling. The patch is based on my i18n branch, but
it should be easy to rebase it on next or master.

What do you think of it?

Cheers,
Christopher.
-- 
================================
Christopher Bertels
http://www.adztec-independent.de
GPG Key ID: 0x2345b203

[-- Attachment #1.1.2: label_notification.patch --]
[-- Type: application/octet-stream, Size: 3505 bytes --]

diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
index ea61bd4..e3777a2 100644
--- a/lib/sup/poll.rb
+++ b/lib/sup/poll.rb
@@ -45,10 +45,10 @@ EOS
     HookManager.run "before-poll"
 
     BufferManager.flash m('flash.info.polling_for_new_messages')
-    num, numi, from_and_subj, from_and_subj_inbox = @mode.poll
+    num, numi, from_and_subj, from_and_subj_inbox, loaded_labels = @mode.poll
     if num > 0
       msg = num > 1 ? 'loaded_n_new_messages' : 'loaded_one_new_message'
-      BufferManager.flash m("flash.info.#{msg}", :n => num, :m => numi)
+      BufferManager.flash m("flash.info.#{msg}", :n => num, :m => numi, :labels => loaded_labels.map{|l| l.to_s}.join(", "))
     else
       BufferManager.flash m('flash.info.no_new_messages')
     end
@@ -93,7 +93,8 @@ EOS
     total_num = total_numi = 0
     from_and_subj = []
     from_and_subj_inbox = []
-
+    loaded_labels = []
+    
     @mutex.synchronize do
       @poll_sources.each do |source|
 #        yield "source #{source} is done? #{source.done?} (cur_offset #{source.cur_offset} >= #{source.end_offset})"
@@ -124,6 +125,7 @@ EOS
           else
             yield "Found new message at #{m.source_info} with labels #{m.labels.to_a * ','}"
             add_new_message m
+            loaded_labels << m.labels.to_a
             num += 1
             from_and_subj << [m.from && m.from.longname, m.subj]
             if (m.labels & [:inbox, :spam, :deleted, :killed]) == Set.new([:inbox])
@@ -138,11 +140,12 @@ EOS
         total_numi += numi
       end
 
+      loaded_labels = loaded_labels.flatten.uniq - LabelManager::HIDDEN_RESERVED_LABELS - [:inbox, :killed]
       yield "Done polling; loaded #{total_num} new messages total"
       @last_poll = Time.now
       @polling = false
     end
-    [total_num, total_numi, from_and_subj, from_and_subj_inbox]
+    [total_num, total_numi, from_and_subj, from_and_subj_inbox, loaded_labels]
   end
 
   ## like Source#each, but yields successive Message objects, which have their
diff --git a/m17n/de.yaml b/m17n/de.yaml
index 34b1c8d..7f5da8a 100644
--- a/m17n/de.yaml
+++ b/m17n/de.yaml
@@ -26,8 +26,8 @@ flash:
     couldnt_exec_view_cmd: "Konnte Betrachtungsprogramm nicht ausführen, betrachte als Text"
     no_draft_messages: "Keine Entwürfe vorhanden."
     successfully_wrote_file: "Erfolgreich Datei geschrieben: #{fn}."
-    loaded_one_new_message: "1 neue Nachricht geladen, #{m} nach Inbox."
-    loaded_n_new_messages: "#{n} neue Nachrichten geladen, #{m} nach Inbox."
+    loaded_one_new_message: "1 neue Nachricht geladen, #{m} nach Inbox. Labels: #{labels}"
+    loaded_n_new_messages: "#{n} neue Nachrichten geladen, #{m} nach Inbox. Labels: #{labels}"
     loaded_one_thread: "1 Thread geladen"
     loaded_n_threads: "#{n} Threads geladen"
 
diff --git a/m17n/en.yaml b/m17n/en.yaml
index 17dea71..6921803 100644
--- a/m17n/en.yaml
+++ b/m17n/en.yaml
@@ -26,8 +26,8 @@ flash:
     couldnt_exec_view_cmd: "Couldn't execute view command, viewing as text."
     no_draft_messages: "No draft messages."
     successfully_wrote_file: "Successfully wrote #{fn}."
-    loaded_one_new_message: "Loaded 1 new message, #{m} to inbox."
-    loaded_n_new_messages: "Loaded #{n} new messages, #{m} to inbox."
+    loaded_one_new_message: "Loaded 1 new message, #{m} to inbox. Labels: #{labels}"
+    loaded_n_new_messages: "Loaded #{n} new messages, #{m} to inbox. Labels: #{labels}"
     loaded_one_thread: "Loaded 1 thread"
     loaded_n_threads: "Loaded #{n} threads."
 

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

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

                 reply	other threads:[~2009-10-10 14:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1255184817-sup-1561@thinkpad-ubuntu \
    --to=mailinglist@flasht.de \
    --cc=sup-talk@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox