(anchor: HTMLElement)
| 105 | }); |
| 106 | |
| 107 | async function add(anchor: HTMLElement): Promise<false | void> { |
| 108 | const path = new GitHubFileUrl(location.href).filePath; |
| 109 | const prsByFile = await prsByFileCache.get(); |
| 110 | let prs = prsByFile[path]; |
| 111 | |
| 112 | if (!prs) { |
| 113 | return; |
| 114 | } |
| 115 | |
| 116 | // Only appears when editing files from PRs |
| 117 | const editingPrNumber = new URLSearchParams(location.search).get('pr')?.split('/').slice(-1); |
| 118 | if (editingPrNumber) { |
| 119 | prs = prs.filter(pr => pr !== Number(editingPrNumber)); |
| 120 | if (prs.length === 0) { |
| 121 | return; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | const dropdown = getDropdown(prs); |
| 126 | if (anchor.parentElement!.matches('.gap-2')) { |
| 127 | // `isSingleFile` |
| 128 | anchor.before(dropdown); |
| 129 | } else { |
| 130 | // `isEditingFile` |
| 131 | dropdown.classList.add('mr-2'); |
| 132 | anchor.parentElement!.prepend(dropdown); |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | async function init(signal: AbortSignal): Promise<void> { |
| 137 | observe( |
nothing calls this directly
no test coverage detected