commit 70848309b19808d321fbc0c6274d8b7c9ccc100e
parent 00bc2a37da6da9a93497a45e7716e4cc60a36efb
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Tue, 9 Jan 2007 00:19:08 +0000
disabled caching of starred and new values, because we need to do more work for
them to actually be valid (namely, determine thread dirtiness) and because they
don't actually seem to make that much of a difference.
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@234 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
2 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
@@ -45,7 +45,7 @@ class Index
@sources[source.id] = source
end
- def source_for name; @sources.values.find { |s| s.is_source_for? name }; end
+ def source_for uri; @sources.values.find { |s| s.is_source_for? uri }; end
def usual_sources; @sources.values.find_all { |s| s.usual? }; end
def sources; @sources.values; end
@@ -231,8 +231,8 @@ class Index
@index.add_document d
## TODO: figure out why this is sometimes triggered
- #docid, entry = load_entry_for_id m.id
- #raise "just added message #{m.id} but couldn't find it in a search" unless docid
+ docid, entry = load_entry_for_id m.id
+ raise "just added message #{m.id} but couldn't find it in a search" unless docid
true
end
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -1,3 +1,4 @@
+require 'thread'
module Redwood
## subclasses should implement load_threads
@@ -105,7 +106,7 @@ class ThreadIndexMode < LineCursorMode
end
def edit_message
- t = @threads[curpos] or return
+ return unless(t = @threads[curpos])
message, *crap = t.find { |m, *o| m.has_label? :draft }
if message
mode = ResumeMode.new message
@@ -115,16 +116,19 @@ class ThreadIndexMode < LineCursorMode
end
end
- def toggle_starred
- t = @threads[curpos] or return
- @starred_cache[t] = t.toggle_label :starred
+ def toggle_starred t=@threads[curpos]
+ if t.has_label? :starred # if ANY message has a star
+ t.remove_label :starred # remove from all
+ else
+ t.first.add_label :starred # add only to first
+ end
+ @starred_cache[t] = t.first.has_label? :starred
update_text_for_line curpos
cursor_down
end
def multi_toggle_starred threads
- threads.each { |t| @starred_cache[t] = t.toggle_label :starred }
- regen_text
+ threads.each { |t| toggle_starred t }
end
def toggle_archived
@@ -365,8 +369,19 @@ protected
from += "." unless from[-1] == ?\s
end
- new = @new_cache.member?(t) ? @new_cache[t] : @new_cache[t] = t.has_label?(:unread)
- starred = @starred_cache.member?(t) ? @starred_cache[t] : @starred_cache[t] = t.has_label?(:starred)
+
+ ## ok, turns out it's not so simple. messages can be added to the
+ ## threadset at any point, which can affect these values, so i'm
+ ## going to ignore the caches for now.
+ ##
+ ## for real caching to work we'd have to have a dirty mechanism on
+ ## the threadset.
+
+ new = t.has_label?(:unread)
+ # new = @new_cache.member?(t) ? @new_cache[t] : @new_cache[t] = t.has_label?(:unread)
+
+ starred = t.has_label?(:starred)
+ # starred = @starred_cache.member?(t) ? @starred_cache[t] : @starred_cache[t] = t.has_label?(:starred)
dp = (@dp_cache[t] ||= t.direct_participants.any? { |p| AccountManager.is_account? p })
p = (@p_cache[t] ||= (dp || t.participants.any? { |p| AccountManager.is_account? p }))
@@ -392,6 +407,7 @@ private
def initialize_threads
@ts = ThreadSet.new Index.instance
+ @ts_mutex = Mutex.new
@date_cache = {}
@who_cache = {}
@dp_cache = {}