+require 'set'
+
module Redwood
## subclasses should implement:
BufferManager.say("Saving threads...") do |say_id|
dirty_threads.each_with_index do |t, i|
BufferManager.say "Saving modified thread #{i + 1} of #{dirty_threads.length}...", say_id
- t.save Index
+ t.save_state Index
end
end
end
keepl, modifyl = thread.labels.partition { |t| speciall.member? t }
user_labels = BufferManager.ask_for_labels :label, "Labels for thread: ", modifyl, @hidden_labels
-
return unless user_labels
- thread.labels = keepl + user_labels
+
+ thread.labels = Set.new(keepl) + user_labels
user_labels.each { |l| LabelManager << l }
update_text_for_line curpos
LabelManager << l
end
end
+ UpdateManager.relay self, :labeled, t.first
end
regen_text
def authors; map { |m, *o| m.from if m }.compact.uniq; end
- def author_names_and_newness_for_thread t
+ def author_names_and_newness_for_thread t, limit=nil
new = {}
- authors = t.map do |m, *o|
+ authors = Set.new
+ t.each do |m, *o|
next unless m
+ break if limit and authors.size >= limit
name =
if AccountManager.is_account?(m.from)
end
new[name] ||= m.has_label?(:unread)
- name
+ authors << name
end
- authors.compact.uniq.map { |a| [a, new[a]] }
+ authors.to_a.map { |a| [a, new[a]] }
end
+ AUTHOR_LIMIT = 5
def text_for_thread_at line
t, size_widget = @mutex.synchronize { [@threads[line], @size_widgets[line]] }
## format the from column
cur_width = 0
- ann = author_names_and_newness_for_thread t
+ ann = author_names_and_newness_for_thread t, AUTHOR_LIMIT
from = []
ann.each_with_index do |(name, newness), i|
break if cur_width >= from_width