Skip to content

Commit

Permalink
fix: main view will not render
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Feb 21, 2024
1 parent c027e26 commit 96955af
Show file tree
Hide file tree
Showing 5 changed files with 662 additions and 21 deletions.
46 changes: 25 additions & 21 deletions src/queue/worker/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,33 +220,37 @@ class EventComposite {
toResult() {
const { mainView, subView } = this;

const chunked = chunk(subView, 5);
const result = [] as IResult[];

const separator = '\n\n---\n\n';

chunked.forEach((v, i) => {
let title = '';
let eventName = '';
let text = v.map((d) => d.markdown.text).join(separator);

if (i === 0 && mainView) {
title = mainView.markdown.title;
eventName = mainView.eventName;
text = mainView.markdown.text + separator + text;
} else if (subView.length > 0) {
title = subView[0].markdown.title;
eventName = subView[0].eventName;
}
if (subView.length > 0) {
const chunked = chunk(subView, 5);
chunked.forEach((v, i) => {
let title = '';
let eventName = '';
let text = v.map((d) => d.markdown.text).join(separator);

if (i === 0 && mainView) {
title = mainView.markdown.title;
eventName = mainView.eventName;
text = mainView.markdown.text + separator + text;
} else if (subView.length > 0) {
title = subView[0].markdown.title;
eventName = subView[0].eventName;
}

result.push({
eventName,
markdown: {
title,
text,
},
result.push({
eventName,
markdown: {
title,
text,
},
});
});
});
} else if (mainView) {
result.push(mainView);
}

return result;
}
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import _pr2060 from './pr-2060.json';
import _pull_request_edited_base from './pull_request_edited_base.json';
import _pull_request_edited_wip from './pull_request_edited_wip.json';
import _pull_request_review_4_submitted_changes_requested from './pull_request_review_4_submitted_changes_requested.json';
import _pull_request_review_submitted_approved from './pull_request_review_submitted_approved.json';
import _release_published from './release_published.json';

export const pull_request_review_4_submitted_changes_requested =
Expand All @@ -31,4 +32,7 @@ export const antd_mini_release_published =

export const issue_opened_event = _issue_opened as IssuesOpenedEvent;

export const pull_request_review_submitted_approved =
_pull_request_review_submitted_approved as PullRequestReviewSubmittedEvent;

export * from './generated';
Loading

0 comments on commit 96955af

Please sign in to comment.