Skip to content

Rename discussionconversation #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ collect.set('isGist', [
'https://my-little-hub.com/gist',
]);

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

export const isDiscussionList = (url: URL | Location = location): boolean => isGlobalDiscussionList(url) || isRepoDiscussionList(url);
collect.set('isDiscussionList', combinedTestOnly);
export const isConversationList = (url: URL | Location = location): boolean => isGlobalConversationList(url) || isRepoConversationList(url);
collect.set('isConversationList', combinedTestOnly);

export const isLabelList = (url: URL | Location = location): boolean => getRepoPath(url) === 'labels';
collect.set('isLabelList', [
Expand Down Expand Up @@ -172,7 +172,7 @@ collect.set('isPRConflicts', [
export const isConflict = isPRConflicts;
collect.set('isConflict', combinedTestOnly);

/** Any `isDiscussionList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */
/** 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 */
export const isPRList = (url: URL | Location = location): boolean => url.pathname === '/pulls' || getRepoPath(url) === 'pulls';
collect.set('isPRList', [
'https://github.com/pulls',
Expand Down Expand Up @@ -243,8 +243,8 @@ collect.set('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 isRepoTaxonomyDiscussionList
'https://github.com/sindresorhus/refined-github/milestones/1/edit', // Gotcha for isRepoTaxonomyDiscussionList
'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/issues/new/choose', // Gotcha for isRepoIssueList
'https://github.com/sindresorhus/refined-github/issues/templates/edit', // Gotcha for isRepoIssueList
]);
Expand All @@ -254,17 +254,17 @@ export const isEmptyRepo = (): boolean => isRepo() && exists('.blankslate');

export const isEmptyRepoRoot = (): boolean => isRepoRoot() && exists('.blankslate');

export const isRepoTaxonomyDiscussionList = (url: URL | Location = location): boolean => /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(getRepoPath(url)!);
collect.set('isRepoTaxonomyDiscussionList', [
export const isRepoTaxonomyConversationList = (url: URL | Location = location): boolean => /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(getRepoPath(url)!);
collect.set('isRepoTaxonomyConversationList', [
'https://github.com/sindresorhus/refined-github/labels/Priority%3A%20critical',
'https://github.com/sindresorhus/refined-github/milestones/1',
]);

export const isRepoDiscussionList = (url: URL | Location = location): boolean =>
export const isRepoConversationList = (url: URL | Location = location): boolean =>
isRepoPRList(url) ||
isRepoIssueList(url) ||
isRepoTaxonomyDiscussionList(url);
collect.set('isRepoDiscussionList', combinedTestOnly);
isRepoTaxonomyConversationList(url);
collect.set('isRepoConversationList', combinedTestOnly);

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

if (pageDetect.isDiscussionList()) {
if (pageDetect.isConversationList()) {
alert('You’re looking at a issues and PRs list!')
}
```
Expand All @@ -49,13 +49,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.isDiscussionList()) {
if (pageDetect.isConversationList()) {
alert('You’re looking at a issues or PRs list!')
}
```

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