[blam: 6/11] Fix adding an item to a channel



commit c3da27a96d948c56a9d6dd22e92d104648b274db
Author: Carlos MartÃn Nieto <carlos cmartin tk>
Date:   Fri Aug 26 03:00:08 2011 +0200

    Fix adding an item to a channel
    
    Instead of using the id taken from the feed, which may be wrong,
    create an Item from it and use that known-good id from onwards. On the
    way, remove a double-adding, which was causing the database to grow
    endlessly, as we could never get rid of old entries.
    
    Signed-off-by: Carlos MartÃn Nieto <carlos cmartin tk>

 src/Channel.cs |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)
---
diff --git a/src/Channel.cs b/src/Channel.cs
index ee01bfc..006487f 100644
--- a/src/Channel.cs
+++ b/src/Channel.cs
@@ -228,26 +228,17 @@ namespace Imendio.Blam {
 
             LastRefreshed = DateTime.Now;
 
-            foreach(SyndicationItem sitem in feed.Items){
-                Add(new Item(sitem));
-            }
-
             /*
              * The new item list is just the new list, so create it
              * on the spot
              */
             ArrayList nitems = new ArrayList();
             foreach(SyndicationItem sitem in feed.Items){
-                nitems.Add(sitem.Id);
-                if(item_list.Contains(sitem.Id)){
-                    if(sitem.Id == null){
-                        continue;
-                    }
-                    /* We already had it, so just update it */
-                    ItemStore.Get(sitem.Id).Update(sitem);
-                } else {
-                    ItemStore.Add(new Item(sitem));
-                }
+                Item item = new Item(sitem);
+                nitems.Add(item.Id);
+                /* If didn't have it already, add it to the store */
+                if(!item_list.Contains(item.Id))
+                    ItemStore.Add(item);
             }
 
             /*



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