/// <summary> /// Copy constructor /// </summary> /// <param name="copyComment"></param> public Comment(Comment copyComment) { Id = copyComment.Id; Author = copyComment.Author; Body = copyComment.Body; CommentDepth = copyComment.CommentDepth; }
public void CollapseCommentsFromComment(Comment comment) { int foundLevel = -1; int killedComment = 0; // Lock the list lock (m_post.Comments) { // Go through all of the comments for (int i = 0; i < m_post.Comments.Count; i++) { // If found level is set we have already seen the comment if (foundLevel != -1) { // If this comment is higher than the root collapse kill it if (m_post.Comments[i].CommentDepth > foundLevel) { // Remove it m_post.Comments.RemoveAt(i); i--; // Update kill count killedComment++; // Move on continue; } else { // We have found the next comment at the same level or lower // we are done. break; } } // If we are here we haven't found the comment yet. else if (m_post.Comments[i].Id.Equals(comment.Id)) { // We found it! Note the level foundLevel = comment.CommentDepth; } } // We are done, close the comment comment.CollapsedCommentCount = "+" + killedComment; comment.ShowFullComment = false; } }
public void ExpandCommentsFromComment(Comment comment) { // Lock the list lock (m_post.Comments) { lock (m_fullCommentList) { // First, we need to find where in the UI we need to add comments int inserationPoint = -1; int expandRootLevel = 0; for (int i = 0; i < m_post.Comments.Count; i++) { if (m_post.Comments[i].Id.Equals(comment.Id)) { // We found it! inserationPoint = i; expandRootLevel = m_post.Comments[i].CommentDepth; break; } } // Move past the comment inserationPoint++; // Now we have to find the comment in the full list int fullListPoint = -1; for (int i = 0; i < m_fullCommentList.Count; i++) { if (m_fullCommentList[i].Id.Equals(comment.Id)) { // We found it! fullListPoint = i; break; } } // Move past the comment fullListPoint++; // Next, Fill in the comments to the UI list until we hit // a level lower than the original for (int i = fullListPoint; i < m_fullCommentList.Count; i++) { if (m_fullCommentList[i].CommentDepth <= expandRootLevel) { // We found a lower level comment, leave now. break; } // Insert this comment into the UI list m_post.Comments.Insert(inserationPoint, m_fullCommentList[i]); inserationPoint++; } // Set the original comment back to normal comment.ShowFullComment = true; } } }
private void ShareComment(Comment comment) { m_shareComment = comment; // Setup the share contract so we can share data DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += DataTransferManager_DataRequested; DataTransferManager.ShowShareUI(); }
private void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args) { if (m_shareComment != null) { string commentLink = "https://reddit.com" + m_post.Permalink + m_shareComment.Id; // #todo use a markdown-less body text string shareBody = m_shareComment.Body.Length > 50 ? m_shareComment.Body.Substring(0, 50) + "..." : m_shareComment.Body; args.Request.Data.Properties.ApplicationName = "Baconit"; args.Request.Data.Properties.ContentSourceWebLink = new Uri(commentLink, UriKind.Absolute); args.Request.Data.Properties.Title = "A Reddit Post Shared From Baconit"; args.Request.Data.Properties.Description = shareBody; args.Request.Data.SetText($"Check this out! \r\n\r\n{shareBody}\r\n\r\n{commentLink}"); m_shareComment = null; App.BaconMan.TelemetryMan.ReportEvent(this, "CommentShared"); } else { args.Request.FailWithDisplayText("Baconit doesn't have anything to share!"); App.BaconMan.TelemetryMan.ReportUnExpectedEvent(this, "FailedToShareCommentHelperCommentNoShareComment"); } }
public void CopyPermalink_Tapped(Comment comment) { // Get the link and copy the url into the clipboard string commentLink = "https://reddit.com" + m_post.Permalink + comment.Id; DataPackage data = new DataPackage(); data.SetText(commentLink); Clipboard.SetContent(data); }
public async void Expand_Tapped(Comment comment) { // Kick delay to the UI thread so the animations can continue await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { ExpandCommentsFromComment(comment); }); }
public void Share_Tapped(Comment comment) { ShareComment(comment); }
public async void Save_Tapped(Comment comment) { // Update the UI now comment.IsSaved = !comment.IsSaved; // Make the call bool success = await MiscellaneousHelper.SaveOrHideRedditItem(App.BaconMan, "t1_" + comment.Id, comment.IsSaved, null); // If we failed revert if (!success) { comment.IsSaved = !comment.IsSaved; } }
public void DownVote_Tapped(Comment comment) { m_commentCollector.ChangeCommentVote(comment, PostVoteAction.DownVote); }
/// <summary> /// Called when the comment should be deleted /// </summary> public void CommentDeleteRequest(Comment comment) { ((CommentCollector)m_commentCollector.GetCollector()).CommentDeleteRequest(comment); }
public void UpVote_Tapped(Comment comment) { ((CommentCollector)m_commentCollector.GetCollector()).ChangeCommentVote(comment, PostVoteAction.UpVote); }
/// <summary> /// Called when the comment should be deleted /// </summary> public void CommentDeleteRequest(Comment comment) { DeferredCollector<Comment> collector = EnsureCollector(); ((CommentCollector)collector.GetCollector()).CommentDeleteRequest(comment); }
public void DownVote_Tapped(Comment comment) { DeferredCollector<Comment> collector = EnsureCollector(); ((CommentCollector)collector.GetCollector()).ChangeCommentVote(comment, PostVoteAction.DownVote); }