MCPcopy Index your code
hub / github.com/utterance/utterances / insertComment

Method insertComment

src/timeline-component.ts:53–79  ·  view source on GitHub ↗
(comment: IssueComment, incrementCount: boolean)

Source from the content-addressed store, hash-verified

51 }
52
53 public insertComment(comment: IssueComment, incrementCount: boolean) {
54 const component = new CommentComponent(
55 comment,
56 this.user ? this.user.login : null,
57 this.issue!.locked);
58
59 const index = this.timeline.findIndex(x => x.comment.id >= comment.id);
60 if (index === -1) {
61 this.timeline.push(component);
62 this.element.insertBefore(component.element, this.marker);
63 } else {
64 const next = this.timeline[index];
65 const remove = next.comment.id === comment.id;
66 this.element.insertBefore(component.element, next.element);
67 this.timeline.splice(index, remove ? 1 : 0, component);
68 if (remove) {
69 next.element.remove();
70 }
71 }
72
73 if (incrementCount) {
74 this.count++;
75 this.renderCount();
76 }
77
78 scheduleMeasure();
79 }
80
81 public insertPageLoader(insertAfter: IssueComment, count: number, callback: () => void) {
82 const { element: insertAfterElement } = this.timeline.find(x => x.comment.id >= insertAfter.id)!;

Callers 2

submitFunction · 0.80
renderPageFunction · 0.80

Calls 3

renderCountMethod · 0.95
scheduleMeasureFunction · 0.90
removeMethod · 0.80

Tested by

no test coverage detected