[banshee] [Migo] Archive items if MaxItemCount set > 0



commit cfc37e03229e9fb31fa06192a16865e01f3ef064
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Tue Dec 14 18:08:32 2010 -0600

    [Migo] Archive items if MaxItemCount set > 0

 src/Libraries/Migo/Migo.Syndication/Feed.cs     |   18 ++++++++++++++++++
 src/Libraries/Migo/Migo.Syndication/FeedItem.cs |    5 +++++
 2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/Libraries/Migo/Migo.Syndication/Feed.cs b/src/Libraries/Migo/Migo.Syndication/Feed.cs
index 93733c8..827d76d 100644
--- a/src/Libraries/Migo/Migo.Syndication/Feed.cs
+++ b/src/Libraries/Migo/Migo.Syndication/Feed.cs
@@ -403,6 +403,7 @@ namespace Migo.Syndication
             }
 
             if (added_any) {
+               CheckForItemsToArchive ();
                Manager.OnFeedsChanged ();
                CheckForItemsToDownload ();
             }
@@ -560,6 +561,7 @@ namespace Migo.Syndication
         public void Save (bool notify)
         {
             Provider.Save (this);
+            CheckForItemsToArchive ();
 
             if (LastBuildDate > LastAutoDownload) {
                 CheckForItemsToDownload ();
@@ -570,6 +572,22 @@ namespace Migo.Syndication
             }
         }
 
+        private void CheckForItemsToArchive ()
+        {
+            if (MaxItemCount == 0)
+                return;
+
+            int i = 0;
+            foreach (var item in Items) {
+                if (!item.IsRead) {
+                    if (i++ >= MaxItemCount) {
+                        item.IsRead = true;
+                        item.Save (false);
+                    }
+                }
+            }
+        }
+
         private void CheckForItemsToDownload ()
         {
             if (LastDownloadError != FeedDownloadError.None || AutoDownload == FeedAutoDownload.None)
diff --git a/src/Libraries/Migo/Migo.Syndication/FeedItem.cs b/src/Libraries/Migo/Migo.Syndication/FeedItem.cs
index b56012a..89f6911 100644
--- a/src/Libraries/Migo/Migo.Syndication/FeedItem.cs
+++ b/src/Libraries/Migo/Migo.Syndication/FeedItem.cs
@@ -232,6 +232,11 @@ namespace Migo.Syndication
 
         public void Save ()
         {
+            Save (true);
+        }
+
+        internal void Save (bool notify)
+        {
             bool is_new = DbId < 1;
             Provider.Save (this);
             if (enclosure != null) {



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