summaryrefslogtreecommitdiff
path: root/source/features/clear-pr-merge-commit-message.tsx
diff options
context:
space:
mode:
authorGravatar Federico Brigante <me@fregante.com> 2023-04-26 12:30:45 +0800
committerGravatar GitHub <noreply@github.com> 2023-04-26 04:30:45 +0000
commit7bc3a21e7cf9c50b552bd90627a37e3b14084223 (patch)
tree9948413b3f35fb0efea8e23f002c5f00ed476915 /source/features/clear-pr-merge-commit-message.tsx
parent5e01b3941d60eff2fb9edbeaeb3f841504d61bc5 (diff)
downloadrefined-github-7bc3a21e7cf9c50b552bd90627a37e3b14084223.tar.gz
refined-github-7bc3a21e7cf9c50b552bd90627a37e3b14084223.tar.zst
refined-github-7bc3a21e7cf9c50b552bd90627a37e3b14084223.zip
Drop `onConversationHeaderUpdate` listener (#6567)
Diffstat (limited to 'source/features/clear-pr-merge-commit-message.tsx')
-rw-r--r--source/features/clear-pr-merge-commit-message.tsx32
1 files changed, 14 insertions, 18 deletions
diff --git a/source/features/clear-pr-merge-commit-message.tsx b/source/features/clear-pr-merge-commit-message.tsx
index 061ff211..efa2b4ea 100644
--- a/source/features/clear-pr-merge-commit-message.tsx
+++ b/source/features/clear-pr-merge-commit-message.tsx
@@ -6,18 +6,16 @@ import * as pageDetect from 'github-url-detection';
import features from '../feature-manager';
import {getBranches} from '../github-helpers/pr-branches';
import getDefaultBranch from '../github-helpers/get-default-branch';
-import onPrMergePanelOpen from '../github-events/on-pr-merge-panel-open';
-import attachElement from '../helpers/attach-element';
import cleanCommitMessage from '../helpers/clean-commit-message';
import {userCanLikelyMergePR} from '../github-helpers';
+import observe from '../helpers/selector-observer';
const isPrAgainstDefaultBranch = async (): Promise<boolean> => getBranches().base.branch === await getDefaultBranch();
-async function init(): Promise<void | false> {
+async function clear(messageField: HTMLTextAreaElement): Promise<void | false> {
// Only run once so that it doesn't clear the field every time it's opened
features.unload(import.meta.url);
- const messageField = select('textarea#merge_message_field')!;
const originalMessage = messageField.value;
const cleanedMessage = cleanCommitMessage(originalMessage, !await isPrAgainstDefaultBranch());
@@ -26,16 +24,18 @@ async function init(): Promise<void | false> {
}
set(messageField, cleanedMessage ? cleanedMessage + '\n' : '');
- attachElement(messageField, {
- after: () => (
- <div>
- <p className="note">
- The description field was cleared by <a target="_blank" href="https://github.com/refined-github/refined-github/wiki/Extended-feature-descriptions#clear-pr-merge-commit-message" rel="noreferrer">Refined GitHub</a>.
- </p>
- <hr/>
- </div>
- ),
- });
+ messageField.after(
+ <div>
+ <p className="note">
+ The description field was cleared by <a target="_blank" href="https://github.com/refined-github/refined-github/wiki/Extended-feature-descriptions#clear-pr-merge-commit-message" rel="noreferrer">Refined GitHub</a>.
+ </p>
+ <hr/>
+ </div>,
+ );
+}
+
+function init(signal: AbortSignal): void {
+ observe('textarea#merge_message_field', clear, {signal});
}
void features.add(import.meta.url, {
@@ -49,10 +49,6 @@ void features.add(import.meta.url, {
// Don't clear 1-commit PRs #3140
() => select.all('.TimelineItem.js-commit').length === 1,
],
- additionalListeners: [
- onPrMergePanelOpen,
- ],
- onlyAdditionalListeners: true,
awaitDomReady: true, // Appears near the end of the page anyway
init,
});