Skip to content

Commit

Permalink
always render merge warning as a last element of PR comment body
Browse files Browse the repository at this point in the history
  • Loading branch information
rikukissa committed Jan 11, 2018
1 parent 8f8a008 commit 3472664
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/features/merge-warning/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,20 @@ function ParentPullRequestWarning(pullRequest: IGithubPullRequest) {
);
}

function render(node: JSX.Element, $container: Element) {
if (!$container.lastElementChild) {
return;
}
$container.insertBefore(
toDOMNode(node),
$container.lastElementChild.nextSibling
);
}

export default async function initialize(context: IStackerContext) {
const $comment = document.querySelector(".comment-body");

if (!$comment || !$comment.firstElementChild) {
if (!$comment) {
return;
}

Expand Down Expand Up @@ -127,10 +137,7 @@ export default async function initialize(context: IStackerContext) {
).filter(child => isBasedOn(child, pullRequest));

if (basedPullRequests.length > 0) {
$comment.insertBefore(
toDOMNode(BasedChildrenWarning(basedPullRequests)),
$comment.firstElementChild.nextSibling
);
render(BasedChildrenWarning(basedPullRequests), $comment);

markInitialized($comment);
return;
Expand All @@ -148,10 +155,7 @@ export default async function initialize(context: IStackerContext) {
return;
}

$comment.insertBefore(
toDOMNode(ParentPullRequestWarning(parentPullRequest)),
$comment.firstElementChild.nextSibling
);
render(ParentPullRequestWarning(parentPullRequest), $comment);

markInitialized($comment);
}

0 comments on commit 3472664

Please sign in to comment.