Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: Andrew Pimlott <andrew@pimlott.net>
To: sup-talk <sup-talk@rubyforge.org>
Subject: Re: [sup-talk] Problems with undo archive and thread focus
Date: Thu, 12 Nov 2009 09:30:01 -0800	[thread overview]
Message-ID: <1258045702-sup-9760@pimlott.net> (raw)
In-Reply-To: <1257409101-sup-7780@pc44es141.cs.uni-magdeburg.de>

Excerpts from Matthias Guedemann's message of Thu Nov 05 00:27:25 -0800 2009:
> One is, if you hit 'a' in thread view mode, the thread is archived but undo does
> not work. If you go back to index view and hit 'u' the just archived thread does
> not appear, but the one before.

I was annoyed by this too and found that undo is minimally implemented.
I added undo to thread view, at least for the cases that I care about or
were easy.  I have to say I was discouraged that this was necessary: the
code to archive a thread should all be in one place, and the undo
record should be created there.  There's a lot of code duplication, and
I can't tell if it's because the model and view are too coupled, or
because nobody has bothered to factor it out.

The patch is appended.  (This is the first time I've done this with git.)

> The second is, if I respond to a thread and send the mail, I normally want to
> either archive that mail directly or label and archive it. But the thread is put
> to the front and the focus is on the last place of the thread. Therefore I
> sometimes archive the wrong thread (but undo comes in handy)

That's the next most annying thing for me.  Hope to get a chance to work
on it.

Andrew

Subject: [PATCH] create undo records in thread view

---
 lib/sup/modes/thread-view-mode.rb |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
index 81197c2..2f2d564 100644
--- a/lib/sup/modes/thread-view-mode.rb
+++ b/lib/sup/modes/thread-view-mode.rb
@@ -254,7 +254,8 @@ EOS
   end    
 
   def edit_labels
-    reserved_labels = @thread.labels.select { |l| LabelManager::RESERVED_LABELS.include? l }
+    old_labels = @thread.labels
+    reserved_labels = old_labels.select { |l| LabelManager::RESERVED_LABELS.include? l }
     new_labels = BufferManager.ask_for_labels :label, "Labels for thread: ", @thread.labels
 
     return unless new_labels
@@ -262,6 +263,10 @@ EOS
     new_labels.each { |l| LabelManager << l }
     update
     UpdateManager.relay self, :labeled, @thread.first
+    UndoManager.register "labeling thread" do
+      @thread.labels = old_labels
+      UpdateManager.relay self, :labeled, @thread.first
+    end
   end
 
   def toggle_starred
@@ -476,6 +481,10 @@ EOS
     dispatch op do
       @thread.remove_label :inbox
       UpdateManager.relay self, :archived, @thread.first
+      UndoManager.register "archiving 1 thread" do
+        @thread.apply_label :inbox
+        UpdateManager.relay self, :unarchived, @thread.first
+      end
     end
   end
 
@@ -483,6 +492,10 @@ EOS
     dispatch op do
       @thread.apply_label :spam
       UpdateManager.relay self, :spammed, @thread.first
+      UndoManager.register "marking 1 thread as spam" do
+        @thread.remove_label :spam
+        UpdateManager.relay self, :unspammed, @thread.first
+      end
     end
   end
 
@@ -490,6 +503,10 @@ EOS
     dispatch op do
       @thread.apply_label :deleted
       UpdateManager.relay self, :deleted, @thread.first
+      UndoManager.register "deleting 1 thread" do
+        @thread.remove_label :deleted
+        UpdateManager.relay self, :undeleted, @thread.first
+      end
     end
   end
 
-- 
1.5.6.5

-- 
I've decided to go back to school.  Kindergarden.
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


  reply	other threads:[~2009-11-12 18:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-05  8:27 Matthias Guedemann
2009-11-12 17:30 ` Andrew Pimlott [this message]
2009-11-16  9:42   ` Matthias Guedemann
2009-11-20  4:51   ` Rich Lane

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=1258045702-sup-9760@pimlott.net \
    --to=andrew@pimlott.net \
    --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