| 5 | |
| 6 | // This event ensures that the feature appears exclusively to the person that merged the PR and not anyone who was on the page at the time of the merge |
| 7 | export default async function waitForPrMerge(signal: AbortSignal): Promise<void> { |
| 8 | // It must start listening early or else the animation ID will be generated incorrectly (ancestor) |
| 9 | // WARNING: Be very careful about the value of ancestor if you refactor this code |
| 10 | const mergeEvent = new Promise(resolve => { |
| 11 | // `emphasis` excludes merge commit icons added by `mark-merge-commits-in-list` |
| 12 | observe('.TimelineItem-badge.color-fg-on-emphasis .octicon-git-merge', resolve, {ancestor: 4}); |
| 13 | }); |
| 14 | |
| 15 | await oneEvent(confirmMergeButton, 'click', {signal}); |
| 16 | |
| 17 | // It won't resolve once the signal is aborted |
| 18 | await mergeEvent; |
| 19 | |
| 20 | if (signal.aborted) { |
| 21 | throw new Error('The code shouldn’t have reached this point'); |
| 22 | } |
| 23 | } |