Page 1 of 1

'Auto mark read' option for smart folders

Posted: Sun Jun 06, 2010 10:20 pm
by w31rd0
I'm very interested in the feature described in this message and I'd like to implement it. But respecting the fact I'm very new to Vienna development, I think I need a review of both the feature and the code from some of the mature developers or maintainers.

The questions are:

    1. Regarding the feature itself -- is it OK to allow smart folders modify articles' states? Or should it better be a separate facility, like "Rules" for mail sorting in Apple Mail.

    2. Regarding the code -- is it really done this easy or am I missing something (re-building caches, etc.)? My testing so far shows it works as expected.

It's not actually "the code" yet, just a quick PoC, where the before-mentioned option is replaced with a hard-coded folder name:

Code: Select all

Index: trunk/2.6.0/Database.m
--- trunk/2.6.0/Database.m   (revision 1569)
+++ trunk/2.6.0/Database.m   (working copy)
@@ -2292,6 +2292,13 @@
          [article setBody:text];
          if (folder == nil || ![article isDeleted] || IsTrashFolder(folder))
             [newArray addObject:article];
+         if (IsSmartFolder(folder) && [[folder name] isEqualTo:@"SPAM"])
+         {
+            [self markArticleRead:[article folderId] guid:[article guid] isRead:YES];
+            [article markRead:YES];
+         }
          [folder addArticleToCache:article];
          // Keep our own track of unread articles