summaryrefslogtreecommitdiff
path: root/source/features/default-branch-button.tsx
diff options
context:
space:
mode:
authorGravatar Federico Brigante <me@fregante.com> 2023-05-10 04:32:07 +0800
committerGravatar GitHub <noreply@github.com> 2023-05-10 04:32:07 +0800
commit747b87a6358c729e54148021d44c94e828603e01 (patch)
treedbe2d54ce393ce66bc9ada86655647ed2a586e00 /source/features/default-branch-button.tsx
parent12532fc4c149f5922fffba89ee2624bf3982e975 (diff)
downloadrefined-github-747b87a6358c729e54148021d44c94e828603e01.tar.gz
refined-github-747b87a6358c729e54148021d44c94e828603e01.tar.zst
refined-github-747b87a6358c729e54148021d44c94e828603e01.zip
Reliability fixes for `default-branch-button` (#6629)
Diffstat (limited to 'source/features/default-branch-button.tsx')
-rw-r--r--source/features/default-branch-button.tsx10
1 files changed, 4 insertions, 6 deletions
diff --git a/source/features/default-branch-button.tsx b/source/features/default-branch-button.tsx
index 0f2e400f..2c5b7fa4 100644
--- a/source/features/default-branch-button.tsx
+++ b/source/features/default-branch-button.tsx
@@ -7,16 +7,14 @@ import features from '../feature-manager.js';
import GitHubURL from '../github-helpers/github-url.js';
import {groupButtons} from '../github-helpers/group-buttons.js';
import getDefaultBranch from '../github-helpers/get-default-branch.js';
-import {getCurrentCommittish} from '../github-helpers/index.js';
import observe from '../helpers/selector-observer.js';
import {branchSelector} from '../github-helpers/selectors.js';
+import isDefaultBranch from '../github-helpers/is-default-branch.js';
async function add(branchSelector: HTMLElement): Promise<void> {
- const defaultBranch = await getDefaultBranch();
- const currentBranch = getCurrentCommittish();
-
// Don't show the button if we’re already on the default branch
- if (defaultBranch === currentBranch) {
+ // TODO: Move to `asLongAs` when it accepts async detections
+ if (await isDefaultBranch()) {
return;
}
@@ -26,7 +24,7 @@ async function add(branchSelector: HTMLElement): Promise<void> {
url.route = '';
url.branch = '';
} else {
- url.branch = defaultBranch;
+ url.branch = await getDefaultBranch();
}
const defaultLink = (