diff options
author | 2021-11-30 18:21:15 +0100 | |
---|---|---|
committer | 2021-11-30 18:21:15 +0100 | |
commit | 00d202dc441738dd77ac389937c72023a939be9f (patch) | |
tree | f3f0182253436b4d03c8227fc8faf4ccf59d5f5a /source/features/quick-pr-diff-options.tsx | |
parent | 70b128af495d63210d5ac3e69041c49d21630dd5 (diff) | |
download | refined-github-00d202dc441738dd77ac389937c72023a939be9f.tar.gz refined-github-00d202dc441738dd77ac389937c72023a939be9f.tar.zst refined-github-00d202dc441738dd77ac389937c72023a939be9f.zip |
Fix `quick-pr-diff-options` on compare pages (#5129)
Diffstat (limited to 'source/features/quick-pr-diff-options.tsx')
-rw-r--r-- | source/features/quick-pr-diff-options.tsx | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/source/features/quick-pr-diff-options.tsx b/source/features/quick-pr-diff-options.tsx index 9f6cbc46..ec1ee064 100644 --- a/source/features/quick-pr-diff-options.tsx +++ b/source/features/quick-pr-diff-options.tsx @@ -4,6 +4,7 @@ import * as pageDetect from 'github-url-detection'; import {BookIcon, CheckIcon, DiffIcon, DiffModifiedIcon} from '@primer/octicons-react'; import features from '.'; +import {onDiffFileLoad} from '../github-events/on-fragment-load'; function makeLink(type: string, icon: Element, selected: boolean): JSX.Element { const url = new URL(location.href); @@ -112,7 +113,12 @@ function initCommitAndCompare(): false | void { ); } +const shortcuts = { + 'd w': 'Show/hide whitespaces in diffs', +}; + void features.add(import.meta.url, { + shortcuts, include: [ pageDetect.isPRFiles, pageDetect.isPRCommit, @@ -120,18 +126,22 @@ void features.add(import.meta.url, { exclude: [ pageDetect.isPRFile404, ], - shortcuts: { - 'd w': 'Show/hide whitespaces in diffs', - }, deduplicate: 'has-rgh-inner', init: initPR, }, { + shortcuts, include: [ pageDetect.isSingleCommit, + ], + init: initCommitAndCompare, +}, { + shortcuts, + include: [ pageDetect.isCompare, ], - shortcuts: { - 'd w': 'Show/hide whitespaces in diffs', - }, + additionalListeners: [ + onDiffFileLoad, + ], + onlyAdditionalListeners: true, init: initCommitAndCompare, }); |