diff options
author | 2021-09-26 10:38:53 +0530 | |
---|---|---|
committer | 2021-09-26 12:08:53 +0700 | |
commit | 17d55029b7224038a2daaecf524ce5ec9f5c9ef6 (patch) | |
tree | 0482edd616d4d11663a53aa7a8484eda72108be5 /source/features/useful-not-found-page.tsx | |
parent | fdd2e33dbc61675685eaa914f869c955a305764c (diff) | |
download | refined-github-17d55029b7224038a2daaecf524ce5ec9f5c9ef6.tar.gz refined-github-17d55029b7224038a2daaecf524ce5ec9f5c9ef6.tar.zst refined-github-17d55029b7224038a2daaecf524ce5ec9f5c9ef6.zip |
Meta: Add an `asLongAs` option to `features.add()` (#4800)
Co-authored-by: yakov116 <16872793+yakov116@users.noreply.github.com>
Co-authored-by: Federico Brigante <me@fregante.com>
Diffstat (limited to 'source/features/useful-not-found-page.tsx')
-rw-r--r-- | source/features/useful-not-found-page.tsx | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/source/features/useful-not-found-page.tsx b/source/features/useful-not-found-page.tsx index bebbe1e4..fddc3917 100644 --- a/source/features/useful-not-found-page.tsx +++ b/source/features/useful-not-found-page.tsx @@ -143,18 +143,9 @@ async function showAlternateLink(): Promise<void> { ); } -function init(): false | void { - const parts = parseCurrentURL(); - if (parts.length < 2) { - return false; - } - - void showMissingPart(); - - if (['tree', 'blob', 'edit'].includes(parts[2])) { - void showDefaultBranchLink(); - void showAlternateLink(); - } +function init(): void { + void showDefaultBranchLink(); + void showAlternateLink(); } async function initPRCommit(): Promise<void | false> { @@ -169,10 +160,22 @@ async function initPRCommit(): Promise<void | false> { ); } -void features.add(__filebasename, { - include: [ +void features.add(__filebasename, { + asLongAs: [ + pageDetect.is404, + () => parseCurrentURL().length > 1, + ], + init: showMissingPart, +}, +{ + asLongAs: [ pageDetect.is404, ], + include: [ + pageDetect.isSingleFile, + pageDetect.isRepoTree, + pageDetect.isEditingFile, + ], init: onetime(init), }, { include: [ |