Repository navigation
feat: follow authors and star commits from the keyboard #597
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
Open
fernandofreamunde
wants to merge
31
commits into
dev-null-sh:production
Choose a base branch
from
fernandofreamunde:feat/follow-author-shortcut
base: production
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+588
−10
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
9a365bc
feat: follow a focused commit's author with f
fernandofreamunde 09ae2f6
style: format peekSharedState for the linter
fernandofreamunde f9fea23
test: cover following a focused commit's author with f
fernandofreamunde 477b0fc
Potential fix for pull request finding 'Visually hidden follow button…
fernandofreamunde a73de07
fix: prefer follow state written while a preview is pending
fernandofreamunde 7e79bac
fix: let Vitest start in CI for the follow shortcut suites
fernandofreamunde 0734255
Merge branch 'production' into feat/follow-author-shortcut
fernandofreamunde bcbf8a2
fix: type the empty body_segments in the notification image test
fernandofreamunde ab67de3
Merge remote-tracking branch 'origin/production' into feat/follow-aut…
fernandofreamunde 070cb6d
fix: stop production CI flakes from achievements and Tom search
fernandofreamunde 79dbb82
Merge remote-tracking branch 'origin/production' into feat/follow-aut…
fernandofreamunde 6a6210f
Merge remote-tracking branch 'delme/production' into feat/follow-auth…
fernandofreamunde 19dded7
test: stop special-casing follow unit tests in package.json
fernandofreamunde b79791e
feat: star the focused commit with s
fernandofreamunde 2f83cbc
Merge branch 'production' into feat/follow-author-shortcut
fernandofreamunde 5cc2d8a
Merge remote-tracking branch 'origin/production' into feat/follow-aut…
fernandofreamunde 130666f
Merge branch 'production' into feat/follow-author-shortcut
fernandofreamunde e7e976b
Merge remote-tracking branch 'fork/feat/follow-author-shortcut' into …
fernandofreamunde d59d7eb
Merge remote-tracking branch 'origin/production' into feat/follow-aut…
fernandofreamunde 22f5026
Merge branch 'production' into feat/follow-author-shortcut
fernandofreamunde b49bf9b
Merge branch 'production' into feat/follow-author-shortcut
fernandofreamunde b83517a
fix: keep follow shortcut and reply stars from racing shared state
fernandofreamunde 8561f7f
Merge branch 'production' into feat/follow-author-shortcut
fernandofreamunde 65f6e10
fix: use handle after production renamed username on users
fernandofreamunde 6be40da
Merge remote-tracking branch 'origin/production' into feat/follow-aut…
fernandofreamunde fda2a54
Merge remote-tracking branch 'origin/production' into feat/follow-aut…
fernandofreamunde 32e8950
fix: drive follow shortcut tests through optimistic shared state
fernandofreamunde 850add9
fix: follow with f only for user commit authors
fernandofreamunde 8751fd4
fix: align follow shortcut with visit options and preview races
fernandofreamunde 4649f14
Merge remote-tracking branch 'origin/production' into feat/follow-aut…
fernandofreamunde 8b648e8
Merge remote-tracking branch 'origin/production' into feat/follow-aut…
fernandofreamunde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import { usePage } from '@inertiajs/react'; | ||
| import { useRef } from 'react'; | ||
| import { | ||
| followVisitOptions, | ||
| resolveIsFollowing, | ||
| toggleFollow, | ||
| useIsFollowing, | ||
| } from '@/components/follow-button'; | ||
| import { signIn } from '@/lib/auth'; | ||
| import type { Commit, CursorPaginated, User } from '@/types'; | ||
|
|
||
| /** | ||
| * Keyboard target for `f` on a focused commit: follow or unfollow that commit's author. | ||
| */ | ||
| export function CommitAuthorFollowButton({ | ||
| user, | ||
| keyShortcut, | ||
| }: { | ||
| user: Pick<User, 'id' | 'handle'>; | ||
| keyShortcut?: string; | ||
| }) { | ||
| const { | ||
| component, | ||
| props: { auth, log, commits }, | ||
| } = usePage<{ commits?: CursorPaginated<Commit> }>(); | ||
| const [, setIsFollowing] = useIsFollowing(user, false); | ||
| const isBusy = useRef(false); | ||
|
|
||
| if (auth.user?.id === user.id) { | ||
| return null; | ||
| } | ||
|
|
||
| const onClick = () => { | ||
| if (auth.user === null) { | ||
| signIn(); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| if (isBusy.current) { | ||
| return; | ||
| } | ||
|
|
||
| isBusy.current = true; | ||
|
|
||
| void resolveIsFollowing(user).then((isFollowing) => { | ||
| if (isFollowing === null) { | ||
| isBusy.current = false; | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| toggleFollow( | ||
| user, | ||
| isFollowing, | ||
| setIsFollowing, | ||
| () => { | ||
| isBusy.current = false; | ||
| }, | ||
| followVisitOptions(component, log, commits), | ||
| ); | ||
| }); | ||
| }; | ||
|
|
||
| return ( | ||
| <button | ||
| type="button" | ||
| onClick={onClick} | ||
| aria-label={`Follow or unfollow @${user.handle}`} | ||
| aria-keyshortcuts={keyShortcut} | ||
| tabIndex={-1} | ||
| className="sr-only" | ||
| data-test="commit-follow-author-button" | ||
| > | ||
| Follow or unfollow @{user.handle} | ||
| </button> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.