Skip to content

Commit

Permalink
Re-render comments after new comment posted
Browse files Browse the repository at this point in the history
  • Loading branch information
Anirudh Sanjeev committed Mar 3, 2010
1 parent c2564d0 commit 3de6ecf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
32 changes: 30 additions & 2 deletions BugzillaInterface/QueryService.cs
Expand Up @@ -267,7 +267,7 @@ public void FetchComments ()
int targetId = BugIds.IndexOf (target.bug_id);
Bugs[targetId].Comments.Add(target);
Bugs[targetId].MarkUnread();
Console.WriteLine ("Found a new comment" + target.ToString());
//Console.WriteLine ("Found a new comment" + target.ToString());
}
else
{
Expand All @@ -279,6 +279,15 @@ public void FetchComments ()
}
}

public BugReport BugFromBugId(int bugId)
{
if(BugIds.Contains(bugId))
{
return Bugs[ BugIds.IndexOf ( bugId ) ];
}
return new BugReport();
}

public bool PostComment(int bugId, string text)
{
Console.WriteLine ("Posting comment");
Expand All @@ -292,13 +301,32 @@ public bool PostComment(int bugId, string text)
postCommentParams.comment = text;

// Make the request;
XmlRpcStruct result;
try{
XmlRpcStruct result = Generator.bugProxy.PostComment(postCommentParams);
result = Generator.bugProxy.PostComment(postCommentParams);
}
catch{
return false;
}

// This is probably stupid. Let's reconstruct the entire comment :);
Comment target = new Comment();
target.bug_id = bugId;
target.id = (int)result["id"];
target.text = text;

// Retrieve the author
this.Source = SplatterCore.Instance.Sources[SourceID];
target.author = Source.UserName;

target.time = DateTime.Now;
//target.is_private = false;

// Add the comment to the bug
BugReport bug = BugFromBugId(bugId);

bug.Comments.Add(target);

return true;
}

Expand Down
8 changes: 7 additions & 1 deletion Frontend/MainWindow.cs
Expand Up @@ -276,10 +276,12 @@ public void SyncTreeviewWithBugs ()
{
if(bug.NewCommentFlag)
{
Console.WriteLine ("Bug has unread comments");
bugStore.AppendValues(queryIter, unreadMessageIcon, bug.summary);
}
else
{
Console.WriteLine ("No unread comments");
bugStore.AppendValues(queryIter, null, bug.summary);
}
}
Expand Down Expand Up @@ -342,7 +344,11 @@ protected virtual void PostCommentClicked (object sender, System.EventArgs e)

protected virtual void PostCommentClicked2 (object sender, System.EventArgs e)
{
activeQuery.PostComment(activeBug.id, commentEntryBox.Buffer.Text);
if(activeQuery.PostComment(activeBug.id, commentEntryBox.Buffer.Text))
{
SplatterCore.Instance.SaveState();
DrawCommentsFromReport(activeBug);
}
}


Expand Down

0 comments on commit 3de6ecf

Please sign in to comment.