Exemplo n.º 1
0
 /**
  * Determines if an issue has had new comments added (or removed) based on its last-known comment
  * count in {@link #issueCommentCounts}.
  *
  * @param issue
  * @return true if the issue has changed, false otherwise
  */
 private boolean issueHasNewComments(TurboIssue issue, boolean hasMetadata) {
   if (currentFilterExpression.getQualifierNames().contains(Qualifier.UPDATED) && hasMetadata) {
     return issueNonSelfCommentCounts.containsKey(issue.getId())
         && Math.abs(
                 issueNonSelfCommentCounts.get(issue.getId())
                     - issue.getMetadata().getNonSelfCommentCount())
             > 0;
   } else {
     return issueCommentCounts.containsKey(issue.getId())
         && Math.abs(issueCommentCounts.get(issue.getId()) - issue.getCommentCount()) > 0;
   }
 }
Exemplo n.º 2
0
 /**
  * Updates {@link #issueCommentCounts} with the latest counts. Returns a list of issues which have
  * new comments.
  *
  * @return
  */
 private HashSet<Integer> updateIssueCommentCounts(boolean hasMetadata) {
   HashSet<Integer> result = new HashSet<>();
   for (TurboIssue issue : getIssueList()) {
     if (issueCommentCounts.containsKey(issue.getId())) {
       // We know about this issue; check if it's been updated
       if (issueHasNewComments(issue, hasMetadata)) {
         result.add(issue.getId());
       }
     } else {
       // We don't know about this issue, just put the current comment count.
       issueNonSelfCommentCounts.put(issue.getId(), issue.getMetadata().getNonSelfCommentCount());
       issueCommentCounts.put(issue.getId(), issue.getCommentCount());
     }
   }
   return result;
 }
Exemplo n.º 3
0
  private void setupListView() {
    setVgrow(listView, Priority.ALWAYS);
    setupKeyboardShortcuts();

    listView.setOnItemSelected(
        i -> {
          TurboIssue issue = listView.getItems().get(i);
          ui.triggerEvent(
              new IssueSelectedEvent(
                  issue.getRepoId(), issue.getId(), panelIndex, issue.isPullRequest()));

          // Save the stored comment count as its own comment count.
          // The refreshItems(false) call that follows will remove the highlighted effect of the
          // comment bubble.
          // (if it was there before)
          issueCommentCounts.put(issue.getId(), issue.getCommentCount());
          issueNonSelfCommentCounts.put(
              issue.getId(), issue.getMetadata().getNonSelfCommentCount());
          // We assume we already have metadata, so we pass true to avoid refreshItems from trying
          // to get
          // metadata after clicking.
          refreshItems(true);
        });
  }