/// <summary> /// Called by the consumer when a post should be make the amount of comments. /// </summary> /// <param name="post">The post to have comments noted</param> /// <param name="postPosition">A hint to the position of the post</param> public void MarkPostCommentCount(Post post, int postPosition = 0) { // If the comments are already noted get out of here. if (ReadPostsList.ContainsKey(post.Id) && post.NumComments == ReadPostsList[post.Id]) { return; } // Using the post and suggested index, find the real post and index Post collectionPost = post; FindPostInCurrentCollection(ref collectionPost, ref postPosition); if (collectionPost == null) { // We didn't find it. return; } // Add or update the comment count ReadPostsList[collectionPost.Id] = collectionPost.NumComments; // Save the new list SaveSettings(); // Fire off that a update happened. FireCollectionUpdated(postPosition, new List <Post>() { collectionPost }, false, false); }
/// <summary> /// Called by the consumer when a post should be marked as read. /// </summary> /// <param name="post">The post to be marked as read</param> /// <param name="postPosition">A hint to the position of the post</param> public void MarkPostRead(Post post, int postPosition = 0) { // If the story is already marked get out of here. if (ReadPostsList.ContainsKey(post.Id)) { return; } // Using the post and suggested index, find the real post and index Post collectionPost = post; FindPostInCurrentCollection(ref collectionPost, ref postPosition); if (collectionPost == null) { // We didn't find it. return; } // Add it to the read list. We don't want to note the comments until it is read in comment view. ReadPostsList.Add(collectionPost.Id, -1); // Save the new list SaveSettings(); // Fire off that a update happened. FireCollectionUpdated(postPosition, new List <Post>() { collectionPost }, false, false); }
/// <summary> /// Applies any common formatting to the posts. /// </summary> /// <param name="posts">Posts to be formatted</param> override protected void ApplyCommonFormatting(ref List <Post> posts) { bool isFrontPage = m_subreddit != null && (m_subreddit.IsArtifical || m_subreddit.DisplayName.ToLower().Equals("frontpage")); bool showSubreddit = isFrontPage || m_subreddit == null; foreach (Post post in posts) { // Set the first line DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0); DateTime postTime = origin.AddSeconds(post.CreatedUtc).ToLocalTime(); // if this is going to a subreddit add the user, if this is going to a user add the domain if (m_subreddit != null) { post.SubTextLine1 = TimeToTextHelper.TimeElapseToText(postTime) + $" ago by {post.Author}"; } else { post.SubTextLine1 = TimeToTextHelper.TimeElapseToText(postTime) + $" ago to {post.Domain}"; } // Set the second line post.SubTextLine2PartOne = post.NumComments + (post.NumComments == 1 ? " comment " : " comments "); post.SubTextLine2PartTwo = (showSubreddit ? post.Subreddit.ToLower() : post.Domain); // Set the second line for flipview post.FlipViewSecondary = showSubreddit ? $"r/{post.Subreddit.ToLower()}" : TimeToTextHelper.TimeElapseToText(postTime) + " ago"; // Escape the title, flair, and selftext post.Title = WebUtility.HtmlDecode(post.Title); post.LinkFlairText = WebUtility.HtmlDecode(post.LinkFlairText); if (!String.IsNullOrEmpty(post.Selftext)) { post.Selftext = WebUtility.HtmlDecode(post.Selftext); } // Set the title size post.TitleMaxLines = m_baconMan.UiSettingsMan.SubredditList_ShowFullTitles ? 99 : 2; // Set if we should show the save image or not post.ShowSaveImageMenu = String.IsNullOrWhiteSpace(ImageManager.GetImageUrl(post.Url)) ? Windows.UI.Xaml.Visibility.Collapsed : Windows.UI.Xaml.Visibility.Visible; // Set if this is owned by the current user if (m_baconMan.UserMan.IsUserSignedIn && m_baconMan.UserMan.CurrentUser != null) { post.IsPostOwnedByUser = post.Author.Equals(m_baconMan.UserMan.CurrentUser.Name, StringComparison.OrdinalIgnoreCase); } // Check if it has been read if (ReadPostsList.ContainsKey(post.Id)) { // Set the text color post.TitleTextColor = Color.FromArgb(255, 152, 152, 152); // Set the comments text if we want to. int commentDiff = post.NumComments - ReadPostsList[post.Id]; post.NewCommentText = (ReadPostsList[post.Id] != -1 && commentDiff > 0) ? $"(+{commentDiff})" : String.Empty; } } }
/// <summary> /// Applies any common formatting to the posts. /// </summary> /// <param name="posts">Posts to be formatted</param> override protected void ApplyCommonFormatting(ref List <Post> posts) { bool isFrontPage = m_subreddit.IsArtifical || m_subreddit.DisplayName.ToLower().Equals("frontpage"); foreach (Post post in posts) { // Set the first line DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0); DateTime postTime = origin.AddSeconds(post.CreatedUtc).ToLocalTime(); post.SubTextLine1 = TimeToTextHelper.TimeElapseToText(postTime) + $" ago by {post.Author}"; // Set the second line post.SubTextLine2PartOne = post.NumComments + (post.NumComments == 1 ? " comment " : " comments "); post.SubTextLine2PartTwo = (isFrontPage ? post.Subreddit.ToLower() : post.Domain); // Set the second line for flipview post.FlipViewSecondary = $"r/{post.Subreddit.ToLower()}"; // Escape the title, flair, and selftext post.Title = WebUtility.HtmlDecode(post.Title); post.LinkFlairText = WebUtility.HtmlDecode(post.LinkFlairText); if (!String.IsNullOrEmpty(post.Selftext)) { post.Selftext = WebUtility.HtmlDecode(post.Selftext); // Some times things are double escaped. So do it twice. post.Selftext = WebUtility.HtmlDecode(post.Selftext); } // Don't show link flair on the front page if (isFrontPage) { post.LinkFlairText = ""; } // Set the title size post.TitleMaxLines = m_baconMan.UiSettingsMan.SubredditList_ShowFullTitles ? 99 : 2; // Set if we should show the save image or not post.ShowSaveImageMenu = String.IsNullOrWhiteSpace(ImageManager.GetImageUrl(post.Url)) ? Windows.UI.Xaml.Visibility.Collapsed : Windows.UI.Xaml.Visibility.Visible; // Check if it has been read if (ReadPostsList.ContainsKey(post.Id)) { // Set the text color post.TitleTextColor = Color.FromArgb(255, 152, 152, 152); // Set the comments text if we want to. int commentDiff = post.NumComments - ReadPostsList[post.Id]; post.NewCommentText = (ReadPostsList[post.Id] != -1 && commentDiff > 0) ? $"(+{commentDiff})" : String.Empty; } } }