From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.213.13.12 with SMTP id z12cs1182924ebz; Sun, 3 Jan 2010 22:06:41 -0800 (PST) Received: by 10.224.1.229 with SMTP id 37mr8092153qag.127.1262585200850; Sun, 03 Jan 2010 22:06:40 -0800 (PST) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id 9si19466474qyk.27.2010.01.03.22.06.40; Sun, 03 Jan 2010 22:06:40 -0800 (PST) Received-SPF: pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-devel-bounces@rubyforge.org Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 2652A167830B; Mon, 4 Jan 2010 01:06:40 -0500 (EST) Received: from mail.cnsp.com (mail.cnsp.com [208.3.80.17]) by rubyforge.org (Postfix) with ESMTP id 9910818582AC for ; Mon, 4 Jan 2010 01:06:38 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.cnsp.com (Postfix) with ESMTP id BD512D464AE9 for ; Sun, 3 Jan 2010 23:06:37 -0700 (MST) X-Virus-Scanned: Debian amavisd-new at cnsp.biz Received: from mail.cnsp.com ([127.0.0.1]) by localhost (mail.cnsp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Pc3NWse140hu for ; Sun, 3 Jan 2010 23:06:37 -0700 (MST) Received: from home.mrtheplague.net (coffeehost.tcct.nmt.edu [129.138.3.50]) by mail.cnsp.com (Postfix) with SMTP id 5FF5DD45B5A1 for ; Sun, 3 Jan 2010 23:06:37 -0700 (MST) Received: by home.mrtheplague.net (Postfix, from userid 1000) id 2D35484A6BDD; Sun, 3 Jan 2010 23:06:37 -0700 (MST) From: Anthony Martinez To: sup-devel@rubyforge.org Date: Sun, 3 Jan 2010 23:06:36 -0700 Message-Id: <1262585196-25964-3-git-send-email-pi+sup@pihost.us> X-Mailer: git-send-email 1.6.5 In-Reply-To: <1262585196-25964-2-git-send-email-pi+sup@pihost.us> References: <1262585196-25964-1-git-send-email-pi+sup@pihost.us> <1262585196-25964-2-git-send-email-pi+sup@pihost.us> Subject: [sup-devel] [PATCH 3/3] make the undo hooks also save the threads X-BeenThere: sup-devel@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Sup developer discussion List-Id: Sup developer discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-devel-bounces@rubyforge.org Errors-To: sup-devel-bounces@rubyforge.org Since there is no explicit sync any longer, any action that has an Index.save_thread must also repeat the save when the action is undone. Failure to do this will result in an exception upon quit when the index notices that there are still dirty messages. --- lib/sup/modes/inbox-mode.rb | 4 ++++ lib/sup/modes/thread-index-mode.rb | 18 ++++++++++++------ lib/sup/modes/thread-view-mode.rb | 4 ++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/sup/modes/inbox-mode.rb b/lib/sup/modes/inbox-mode.rb index 852ddb7..1b8eaed 100644 --- a/lib/sup/modes/inbox-mode.rb +++ b/lib/sup/modes/inbox-mode.rb @@ -37,6 +37,7 @@ class InboxMode < ThreadIndexMode UndoManager.register "archiving thread" do thread.apply_label :inbox add_or_unhide thread.first + Index.save_thread thread end cursor_thread.remove_label :inbox @@ -50,6 +51,7 @@ class InboxMode < ThreadIndexMode threads.map do |t| t.apply_label :inbox add_or_unhide t.first + Index.save_thread t end regen_text end @@ -71,6 +73,7 @@ class InboxMode < ThreadIndexMode thread.apply_label :inbox thread.apply_label :unread if was_unread add_or_unhide thread.first + Index.save_thread thread end cursor_thread.remove_label :unread @@ -94,6 +97,7 @@ class InboxMode < ThreadIndexMode threads.zip(old_labels).each do |t, l| t.labels = l add_or_unhide t.first + Index.save_thread t end regen_text end diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb index a5bd344..28cb858 100644 --- a/lib/sup/modes/thread-index-mode.rb +++ b/lib/sup/modes/thread-index-mode.rb @@ -265,7 +265,7 @@ EOS def toggle_starred t = cursor_thread or return undo = actually_toggle_starred t - UndoManager.register "toggling thread starred status", undo + UndoManager.register "toggling thread starred status", undo, lambda { Index.save_thread t } update_text_for_line curpos cursor_down Index.save_thread t @@ -273,7 +273,8 @@ EOS def multi_toggle_starred threads UndoManager.register "toggling #{threads.size.pluralize 'thread'} starred status", - threads.map { |t| actually_toggle_starred t } + threads.map { |t| actually_toggle_starred t }, + lambda { threads.each { |t| Index.save_thread t } } regen_text threads.each { |t| Index.save_thread t } end @@ -351,14 +352,16 @@ EOS def toggle_archived t = cursor_thread or return undo = actually_toggle_archived t - UndoManager.register "deleting/undeleting thread #{t.first.id}", undo, lambda { update_text_for_line curpos } + UndoManager.register "deleting/undeleting thread #{t.first.id}", undo, lambda { update_text_for_line curpos }, + lambda { Index.save_thread t } update_text_for_line curpos Index.save_thread t end def multi_toggle_archived threads undos = threads.map { |t| actually_toggle_archived t } - UndoManager.register "deleting/undeleting #{threads.size.pluralize 'thread'}", undos, lambda { regen_text } + UndoManager.register "deleting/undeleting #{threads.size.pluralize 'thread'}", undos, lambda { regen_text }, + lambda { threads.each { |t| Index.save_thread t } } regen_text threads.each { |t| Index.save_thread t } end @@ -425,7 +428,7 @@ EOS undos = threads.map { |t| actually_toggle_spammed t } threads.each { |t| HookManager.run("mark-as-spam", :thread => t) } UndoManager.register "marking/unmarking #{threads.size.pluralize 'thread'} as spam", - undos, lambda { regen_text } + undos, lambda { regen_text }, lambda { threads.each { |t| Index.save_thread t } } regen_text threads.each { |t| Index.save_thread t } end @@ -439,7 +442,7 @@ EOS def multi_toggle_deleted threads undos = threads.map { |t| actually_toggle_deleted t } UndoManager.register "deleting/undeleting #{threads.size.pluralize 'thread'}", - undos, lambda { regen_text } + undos, lambda { regen_text }, lambda { threads.each { |t| Index.save_thread t } } regen_text threads.each { |t| Index.save_thread t } end @@ -455,6 +458,7 @@ EOS threads.each do |t| t.remove_label :killed add_or_unhide t.first + Index.save_thread t end regen_text end @@ -530,6 +534,7 @@ EOS thread.labels = old_labels update_text_for_line pos UpdateManager.relay self, :labeled, thread.first + Index.save_thread thread end UpdateManager.relay self, :labeled, thread.first @@ -567,6 +572,7 @@ EOS threads.zip(old_labels).map do |t, old_labels| t.labels = old_labels UpdateManager.relay self, :labeled, t.first + Index.save_thread t end regen_text end diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb index 7c0b869..b08c819 100644 --- a/lib/sup/modes/thread-view-mode.rb +++ b/lib/sup/modes/thread-view-mode.rb @@ -279,6 +279,7 @@ EOS Index.save_thread @thread UndoManager.register "labeling thread" do @thread.labels = old_labels + Index.save_thread @thread UpdateManager.relay self, :labeled, @thread.first end end @@ -527,6 +528,7 @@ EOS Index.save_thread @thread UndoManager.register "archiving 1 thread" do @thread.apply_label :inbox + Index.save_thread @thread UpdateManager.relay self, :unarchived, @thread.first end end @@ -539,6 +541,7 @@ EOS Index.save_thread @thread UndoManager.register "marking 1 thread as spam" do @thread.remove_label :spam + Index.save_thread @thread UpdateManager.relay self, :unspammed, @thread.first end end @@ -551,6 +554,7 @@ EOS Index.save_thread @thread UndoManager.register "deleting 1 thread" do @thread.remove_label :deleted + Index.save_thread @thread UpdateManager.relay self, :undeleted, @thread.first end end -- 1.6.5 _______________________________________________ Sup-devel mailing list Sup-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-devel