Skip to content

Commit

Permalink
Replace "Conversation" with "IssueOrPR" for clarity (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Jul 24, 2022
1 parent b456414 commit 2d1f30e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
28 changes: 14 additions & 14 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ addTests('isGist', [
'https://gist.github.com/kidonng/0d16c7f17045f486751fad1b602204a0/revisions',
]);

export const isGlobalConversationList = (url: URL | HTMLAnchorElement | Location = location): boolean => ['issues', 'pulls'].includes(url.pathname.split('/', 2)[1]!);
addTests('isGlobalConversationList', [
export const isGlobalIssueOrPRList = (url: URL | HTMLAnchorElement | Location = location): boolean => ['issues', 'pulls'].includes(url.pathname.split('/', 2)[1]!);
addTests('isGlobalIssueOrPRList', [
'https://github.com/issues',
'https://github.com/issues?q=is%3Apr+is%3Aopen',
'https://github.com/issues/assigned',
Expand All @@ -122,11 +122,11 @@ addTests('isIssue', [
'https://github.com/sindresorhus/refined-github/issues/146',
]);

export const isConversationList = (url: URL | HTMLAnchorElement | Location = location): boolean =>
isGlobalConversationList(url)
|| isRepoConversationList(url)
export const isIssueOrPRList = (url: URL | HTMLAnchorElement | Location = location): boolean =>
isGlobalIssueOrPRList(url)
|| isRepoIssueOrPRList(url)
|| isMilestone(url);
addTests('isConversationList', combinedTestOnly);
addTests('isIssueOrPRList', combinedTestOnly);

export const isConversation = (url: URL | HTMLAnchorElement | Location = location): boolean => isIssue(url) || isPRConversation(url);
addTests('isConversation', combinedTestOnly);
Expand Down Expand Up @@ -222,7 +222,7 @@ addTests('isPRConflicts', [
'https://github.com/sindresorhus/refined-github/pull/148/conflicts',
]);

/** Any `isConversationList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */
/** Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */
export const isPRList = (url: URL | HTMLAnchorElement | Location = location): boolean => url.pathname === '/pulls' || getRepo(url)?.path === 'pulls';
addTests('isPRList', [
'https://github.com/pulls',
Expand Down Expand Up @@ -339,8 +339,8 @@ addTests('isRepo', [
'https://github.com/sindresorhus/refined-github/issues/146',
'https://github.com/sindresorhus/notifications/',
'https://github.com/sindresorhus/refined-github/pull/148',
'https://github.com/sindresorhus/refined-github/milestones/new', // Gotcha for isRepoTaxonomyConversationList
'https://github.com/sindresorhus/refined-github/milestones/1/edit', // Gotcha for isRepoTaxonomyConversationList
'https://github.com/sindresorhus/refined-github/milestones/new', // Gotcha for isRepoTaxonomyIssueOrPRList
'https://github.com/sindresorhus/refined-github/milestones/1/edit', // Gotcha for isRepoTaxonomyIssueOrPRList
'https://github.com/sindresorhus/refined-github/issues/new/choose', // Gotcha for isRepoIssueList
'https://github.com/sindresorhus/refined-github/issues/templates/edit', // Gotcha for isRepoIssueList
]);
Expand All @@ -354,19 +354,19 @@ export const isArchivedRepo = (): boolean => Boolean(isRepo() && $('#repository-

export const isBlank = (): boolean => exists('main .blankslate');

export const isRepoTaxonomyConversationList = (url: URL | HTMLAnchorElement | Location = location): boolean => /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(getRepo(url)?.path!);
addTests('isRepoTaxonomyConversationList', [
export const isRepoTaxonomyIssueOrPRList = (url: URL | HTMLAnchorElement | Location = location): boolean => /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(getRepo(url)?.path!);
addTests('isRepoTaxonomyIssueOrPRList', [
'https://github.com/sindresorhus/refined-github/labels/bug',
'https://github.com/sindresorhus/refined-github/labels/implemented%20by%20github',
'https://github.com/sindresorhus/refined-github/labels/%3Adollar%3A%20Funded%20on%20Issuehunt',
'https://github.com/sindresorhus/refined-github/milestones/1',
]);

export const isRepoConversationList = (url: URL | HTMLAnchorElement | Location = location): boolean =>
export const isRepoIssueOrPRList = (url: URL | HTMLAnchorElement | Location = location): boolean =>
isRepoPRList(url)
|| isRepoIssueList(url)
|| isRepoTaxonomyConversationList(url);
addTests('isRepoConversationList', combinedTestOnly);
|| isRepoTaxonomyIssueOrPRList(url);
addTests('isRepoIssueOrPRList', combinedTestOnly);

export const isRepoPRList = (url: URL | HTMLAnchorElement | Location = location): boolean => Boolean(getRepo(url)?.path.startsWith('pulls'));
addTests('isRepoPRList', [
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (pageDetect.isRepo()) { // Uses `window.location.href` by default
alert('You’re looking at a repo!')
}

if (pageDetect.isConversationList()) {
if (pageDetect.isIssueOrPRList()) {
alert('You’re looking at a issues and PRs list!')
}
```
Expand All @@ -44,13 +44,13 @@ Most detections are URL-based while others need access to the current `document`
By default, URL-based detections use the `location` global if you don't pass a `url` argument.

```js
if (pageDetect.isConversationList()) {
if (pageDetect.isIssueOrPRList()) {
alert('You’re looking at a issues or PRs list!')
}
```

```js
if (pageDetect.isConversationList(new URL('https://github.com/refined-github/github-url-detection/pulls'))) {
if (pageDetect.isIssueOrPRList(new URL('https://github.com/refined-github/github-url-detection/pulls'))) {
alert('You’re looking at a issues or PRs list!')
}
```
Expand Down

0 comments on commit 2d1f30e

Please sign in to comment.