[tomboy] Don't save unchanged new notes



commit 21bfeccf54387a5fe8d2ef576ca72da765c84518
Author: Benjamin Podszun <benjamin podszun gmail com>
Date:   Tue Apr 19 11:15:36 2011 +0200

    Don't save unchanged new notes
    
    Supresses Note.Save () calls if the note title matches the new note
    title pattern & the content is the unchanged new note template text.
    
    Signed-off-by: Aaron Borden <adborden live com>

 Tomboy/Note.cs |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/Tomboy/Note.cs b/Tomboy/Note.cs
index 86002e3..cf332cf 100644
--- a/Tomboy/Note.cs
+++ b/Tomboy/Note.cs
@@ -494,6 +494,16 @@ namespace Tomboy
 			if (!save_needed)
 				return;
 
+			string new_note_pattern = String.Format (Catalog.GetString ("New Note {0}"), @"\d+");
+			Note template_note = manager.GetOrCreateTemplateNote ();
+			string template_content = template_note.TextContent.Replace (template_note.Title, Title);
+
+			// Do nothing if this note contains the unchanged template content
+			// and if the title matches the new note title template to prevent
+			// lots of unwanted "New Note NNN" notes: Bug #545252
+			if (Regex.IsMatch (Title, new_note_pattern) && TextContent.Equals (template_content))
+				return;
+
 			Logger.Debug ("Saving '{0}'...", data.Data.Title);
 
 			try {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]