Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCH] Handle drafts with high ID numbers.
@ 2012-08-29  0:35 Edward Z. Yang
  2012-08-29  0:41 ` Edward Z. Yang
  0 siblings, 1 reply; 2+ messages in thread
From: Edward Z. Yang @ 2012-08-29  0:35 UTC (permalink / raw)
  To: sup-devel; +Cc: btricha

From: "Edward Z. Yang" <ezyang@mit.edu>

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
---
 lib/sup/draft.rb | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/lib/sup/draft.rb b/lib/sup/draft.rb
index 58c45db..1f33dc1 100644
--- a/lib/sup/draft.rb
+++ b/lib/sup/draft.rb
@@ -37,7 +37,6 @@ class DraftLoader < Source
     Dir.mkdir dir unless File.exists? dir
     super DraftManager.source_name, true, false
     @dir = dir
-    @cur_offset = 0
   end
 
   def id; DraftManager.source_id; end
@@ -46,14 +45,13 @@ class DraftLoader < Source
 
   def poll
     ids = get_ids
-    ids.each do |id|
-      if id >= @cur_offset
-        @cur_offset = id + 1
-        yield :add,
-          :info => id,
-          :labels => [:draft, :inbox],
-          :progress => 0.0
-      end
+    old_ids = Enumerator.new(Index.instance, :each_source_info, self.id).to_a
+    new_ids = ids - old_ids
+    new_ids.each do |id|
+      yield :add,
+        :info => id,
+        :labels => [:draft, :inbox],
+        :progress => 0.0
     end
   end
 
-- 
1.7.11.3

_______________________________________________
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] [PATCH] Handle drafts with high ID numbers.
  2012-08-29  0:35 [sup-devel] [PATCH] Handle drafts with high ID numbers Edward Z. Yang
@ 2012-08-29  0:41 ` Edward Z. Yang
  0 siblings, 0 replies; 2+ messages in thread
From: Edward Z. Yang @ 2012-08-29  0:41 UTC (permalink / raw)
  To: sup-devel, btricha

If you've ever suffered from saving a draft message, and then
suddenly asking, "Where did it go?" because it didn't show up
in your INBOX, try this patch.

Edward

Excerpts from Edward Z. Yang's message of Tue Aug 28 20:35:01 -0400 2012:
> From: "Edward Z. Yang" <ezyang@mit.edu>
> 
> Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
> ---
>  lib/sup/draft.rb | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/lib/sup/draft.rb b/lib/sup/draft.rb
> index 58c45db..1f33dc1 100644
> --- a/lib/sup/draft.rb
> +++ b/lib/sup/draft.rb
> @@ -37,7 +37,6 @@ class DraftLoader < Source
>      Dir.mkdir dir unless File.exists? dir
>      super DraftManager.source_name, true, false
>      @dir = dir
> -    @cur_offset = 0
>    end
>  
>    def id; DraftManager.source_id; end
> @@ -46,14 +45,13 @@ class DraftLoader < Source
>  
>    def poll
>      ids = get_ids
> -    ids.each do |id|
> -      if id >= @cur_offset
> -        @cur_offset = id + 1
> -        yield :add,
> -          :info => id,
> -          :labels => [:draft, :inbox],
> -          :progress => 0.0
> -      end
> +    old_ids = Enumerator.new(Index.instance, :each_source_info, self.id).to_a
> +    new_ids = ids - old_ids
> +    new_ids.each do |id|
> +      yield :add,
> +        :info => id,
> +        :labels => [:draft, :inbox],
> +        :progress => 0.0
>      end
>    end
>  
_______________________________________________
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:[~2012-08-29  0:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-29  0:35 [sup-devel] [PATCH] Handle drafts with high ID numbers Edward Z. Yang
2012-08-29  0:41 ` Edward Z. Yang

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