[blam] Item: Store content in the Summary field



commit 1757ac3f9cc28cd807e0c5cc468e20d30ef5f0d4
Author: Carlos Martín Nieto <carlos cmartin tk>
Date:   Sun Mar 27 17:37:48 2011 +0200

    Item: Store content in the Summary field
    
    The feed parser only writes out the summary field, so store the data
    there.
    
    Signed-off-by: Carlos Martín Nieto <carlos cmartin tk>

 src/Item.cs     |   24 ++++++++----------------
 src/ItemView.cs |    3 +--
 2 files changed, 9 insertions(+), 18 deletions(-)
---
diff --git a/src/Item.cs b/src/Item.cs
index dc8ebf9..ec82c5a 100644
--- a/src/Item.cs
+++ b/src/Item.cs
@@ -18,8 +18,6 @@ namespace Imendio.Blam {
 
         private int ref_cnt = 0;
         private Object obj = new Object();
-        private bool init = false;
-        public SyndicationContent exposed_text = null;
 
         public delegate void UpdateHandler(Item item);
         public event UpdateHandler Updated;
@@ -78,25 +76,20 @@ namespace Imendio.Blam {
         private void FillItem(SyndicationItem item)
         {
             if(this.Id == null){
-                this.Id = this.Links[0].Uri.ToString();
-            }
-
-            if(item.Summary != null && item.Summary.Text != ""){
-                this.exposed_text = item.Summary;
+                if(item.Id == null)
+                    this.Id = item.Links[0].Uri.ToString();
+                else
+                    this.Id = item.Id;
             }
 
             if(item.Content != null){
-                this.exposed_text = item.Content;
+                /* The feed formatters only store the summary */
+                this.Summary = item.Content as TextSyndicationContent;
             }
 
-            foreach(SyndicationElementExtension ext in this.ElementExtensions){
+            foreach(SyndicationElementExtension ext in item.ElementExtensions){
                 if(ext.OuterName == "encoded"){
-                    item.Content = new TextSyndicationContent(ext.GetObject<string>());
-                    exposed_text = item.Content;
-                }
-
-                if(init){
-                    return;
+                    this.Summary = new TextSyndicationContent(ext.GetObject<string>());
                 }
 
                 switch(ext.OuterNamespace){
@@ -128,7 +121,6 @@ namespace Imendio.Blam {
         {
             lock(obj){
                 FillItem(item);
-                init = true;
             }
         }
 
diff --git a/src/ItemView.cs b/src/ItemView.cs
index 1407a62..9490a33 100644
--- a/src/ItemView.cs
+++ b/src/ItemView.cs
@@ -113,8 +113,7 @@ namespace Imendio.Blam {
 				(!currentItem.PublishDate.Equals(DateTimeOffset.MinValue)) ?
                   currentItem.PublishDate.ToString("D", System.Globalization.CultureInfo.CurrentUICulture) :
 				  Catalog.GetString("[No date available]");
-			TextSyndicationContent cont = currentItem.exposed_text as TextSyndicationContent;
-			string text = cont.Text;
+			string text = currentItem.Summary.Text;
             //string text    = (currentItem.exposed_text as TextSyndicationContent).Text;
             string title   = HtmlUtils.Escape(currentItem.Title.Text);
             string url     = currentItem.Links[0].Uri.ToString();



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