summaryrefslogtreecommitdiff
path: root/Juick/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/ViewModels')
-rw-r--r--Juick/ViewModels/PostItem.cs20
-rw-r--r--Juick/ViewModels/ViewModelBase.cs17
2 files changed, 13 insertions, 24 deletions
diff --git a/Juick/ViewModels/PostItem.cs b/Juick/ViewModels/PostItem.cs
index 7e30a43..2072cf5 100644
--- a/Juick/ViewModels/PostItem.cs
+++ b/Juick/ViewModels/PostItem.cs
@@ -8,23 +8,24 @@ namespace Juick.ViewModels
{
public class PostItem
{
- public PostItem()
- {
-
- }
-
public PostItem(Message message)
{
MID = message.Mid;
- MessageUri = string.Format("/ThreadView.xaml?mid={0}", MID);
RID = message.Rid;
Username = message.User.UName;
+ Status = string.Format("Posted on: {0}, replies: {1}", message.Timestamp, message.Replies);
+
MessageText = HttpUtility.HtmlDecode(message.Body);
if (message.Tags != null)
{
MessageText = string.Join(", ", message.Tags) + Environment.NewLine + MessageText;
}
+ AvatarUri = new Uri(string.Format("http://i.juick.com/as/{0}.png", message.User.Uid), UriKind.Absolute);
+ if (message.Photo != null)
+ {
+ Attachment = new Uri(message.Photo.Small, UriKind.Absolute);
+ }
}
public int MID {get;set;}
@@ -36,11 +37,10 @@ namespace Juick.ViewModels
public Uri AvatarUri {get;set;}
public Uri Attachment {get;set;}
-
- public string MessageText {get;set;}
+
public string Status {get;set;}
-
- public string MessageUri {get;set;}
+
+ public string MessageText { get; set; }
}
} \ No newline at end of file
diff --git a/Juick/ViewModels/ViewModelBase.cs b/Juick/ViewModels/ViewModelBase.cs
index e86ff4a..2427a80 100644
--- a/Juick/ViewModels/ViewModelBase.cs
+++ b/Juick/ViewModels/ViewModelBase.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
@@ -88,20 +89,8 @@ namespace Juick.ViewModels
}
//Items.Clear();
- foreach (var post in response.Data)
- {
- var status = string.Format("Posted on: {0}, replies: {1}", post.Timestamp, post.Replies);
- var item = new PostItem(post)
- {
- Status = status,
- AvatarUri = new Uri(string.Format("http://i.juick.com/as/{0}.png", post.User.Uid), UriKind.Absolute)
- };
- if (post.Photo != null)
- {
- item.Attachment = new Uri(post.Photo.Small, UriKind.Absolute) ;
- }
- Items.Add(item);
- }
+ response.Data.Select(x => new PostItem(x)).ToList().ForEach(i => Items.Add(i));
+
}