]> git.cworth.org Git - sup/commitdiff
Merge branch 'master' into next
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Sat, 22 Aug 2009 14:49:59 +0000 (10:49 -0400)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Sat, 22 Aug 2009 14:49:59 +0000 (10:49 -0400)
1  2 
lib/sup/thread.rb

diff --combined lib/sup/thread.rb
index ca3f30d08cffabdab36225ac68e274fd5092184c,3ff4e7f1a8b25a07fdd504edf4eb3057954156b2..2300305c0710da7dfcb55891b5967abdc27e7f8f
@@@ -24,8 -24,6 +24,8 @@@
  ## a faked root object tying them all together into one tree
  ## structure.
  
 +require 'set'
 +
  module Redwood
  
  class Thread
    def toggle_label label
      if has_label? label
        remove_label label
 -      return false
 +      false
      else
        apply_label label
 -      return true
 +      true
      end
    end
  
    def set_labels l; each { |m, *o| m && m.labels = l }; end
 -  
    def has_label? t; any? { |m, *o| m && m.has_label?(t) }; end
 -  def save index; each { |m, *o| m && m.save(index) }; end
 +  def save_state index; each { |m, *o| m && m.save_state(index) }; end
  
    def direct_participants
      map { |m, *o| [m.from] + m.to if m }.flatten.compact.uniq
  
    def size; map { |m, *o| m ? 1 : 0 }.sum; end
    def subj; argfind { |m, *o| m && m.subj }; end
 -  def labels
 -      map { |m, *o| m && m.labels }.flatten.compact.uniq.sort_by { |t| t.to_s }
 -  end
 +  def labels; inject(Set.new) { |s, (m, *o)| m ? s | m.labels : s } end
    def labels= l
 -    each { |m, *o| m && m.labels = l.clone }
 +    raise ArgumentError, "not a set" unless l.is_a?(Set)
 +    each { |m, *o| m && m.labels = l.dup }
    end
  
    def latest_message
 -    inject(nil) do |a, b| 
 +    inject(nil) do |a, b|
        b = b.first
        if a.nil?
          b
@@@ -162,7 -162,7 +162,7 @@@ class Containe
      @id = id
      @message, @parent, @thread = nil, nil, nil
      @children = []
 -  end      
 +  end
  
    def each_with_stuff parent=nil
      yield self, 0, parent
@@@ -357,7 -357,7 +357,7 @@@ class ThreadSe
      return if threads.size < 2
  
      containers = threads.map do |t|
-       c = @messages.member?(c) ? @messages[t.first.id] : nil
+       c = @messages.member?(t.first.id) ? @messages[t.first.id] : nil
        raise "not in threadset: #{t.first.id}" unless c && c.message
        c
      end