From 9f9fa9ead89cd6f7e148fe90fb553ddc24d8fe37 Mon Sep 17 00:00:00 2001 From: Eduardo Cruz Date: Tue, 20 Oct 2026 23:49:09 +0000 Subject: [PATCH 1/2] fix: adds back button to user profiles Opening a profile from a thread left no way back in the iOS standalone app, which has no browser back button. Extracts the commit page's back behaviour into a useGoBack hook and reuses it in the profile header. Fixes nunomaduro/dev-null.sh#903 --- resources/js/hooks/use-go-back.ts | 17 +++++++++++++++++ resources/js/pages/commit/show.tsx | 17 +++-------------- resources/js/pages/user/show.tsx | 12 ++++++++++++ 3 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 resources/js/hooks/use-go-back.ts diff --git a/resources/js/hooks/use-go-back.ts b/resources/js/hooks/use-go-back.ts new file mode 100644 index 000000000..6df81764f --- /dev/null +++ b/resources/js/hooks/use-go-back.ts @@ -0,0 +1,17 @@ +import { router, usePage } from '@inertiajs/react'; +import LogController from '@/actions/App/Http/Controllers/LogController'; +import { home } from '@/routes'; + +export function useGoBack(): () => void { + const { auth } = usePage().props; + + return () => { + if (window.history.length > 1) { + window.history.back(); + + return; + } + + router.visit(auth.log === null ? home() : LogController.show(auth.log)); + }; +} diff --git a/resources/js/pages/commit/show.tsx b/resources/js/pages/commit/show.tsx index a2e8f6134..deece6c79 100644 --- a/resources/js/pages/commit/show.tsx +++ b/resources/js/pages/commit/show.tsx @@ -1,13 +1,12 @@ -import { Head, router, usePage } from '@inertiajs/react'; +import { Head } from '@inertiajs/react'; import { ArrowLeft } from 'lucide-react'; -import LogController from '@/actions/App/Http/Controllers/LogController'; import { CommitCard, CommitTombstone } from '@/components/commit-card'; import { CopyLinkButton } from '@/components/copy-link-button'; import { GraphCanvas } from '@/components/graph-canvas'; import { useContinuation } from '@/hooks/use-continuation'; +import { useGoBack } from '@/hooks/use-go-back'; import AppLayout from '@/layouts/app-layout'; import { isDeleted, laneOf, shortHash } from '@/lib/utils'; -import { home } from '@/routes'; import type { Commit, CursorPaginated, @@ -28,7 +27,7 @@ export default function Show({ continuation: ThreadContinuation; replies: CursorPaginated | null; }) { - const { auth } = usePage().props; + const goBack = useGoBack(); const { shown, nextId, size, isCapped, isLoading, loadMore } = useContinuation(continuation); const focusedPosition = continuation.position; @@ -40,16 +39,6 @@ export default function Show({ ? `${commit.body.slice(0, titleLength).trimEnd()}…` : commit.body; - const goBack = () => { - if (window.history.length > 1) { - window.history.back(); - - return; - } - - router.visit(auth.log === null ? home() : LogController.show(auth.log)); - }; - const lastAncestor = ancestors.at(-1); return ( diff --git a/resources/js/pages/user/show.tsx b/resources/js/pages/user/show.tsx index 7416d8021..cf0d4cc6b 100644 --- a/resources/js/pages/user/show.tsx +++ b/resources/js/pages/user/show.tsx @@ -1,5 +1,6 @@ import { Head, Link, router, usePage } from '@inertiajs/react'; import { + ArrowLeft, Building2, CalendarDays, Heart, @@ -39,6 +40,7 @@ import { UserModerationStatus, } from '@/components/user-moderation-menu'; import { UserSafetyMenu } from '@/components/user-safety-menu'; +import { useGoBack } from '@/hooks/use-go-back'; import { refreshSharedState, useSharedState } from '@/hooks/use-shared-state'; import AppLayout from '@/layouts/app-layout'; import { commitStateKey } from '@/lib/commit-state'; @@ -88,6 +90,7 @@ export default function Show({ }) { const { auth } = usePage().props; const isCurrentUser = auth.user?.id === user.id; + const goBack = useGoBack(); const lane = laneColor(user.lane); const [highlightedPeriod, setHighlightedPeriod] = useState( null, @@ -116,6 +119,15 @@ export default function Show({
+

{user.name}

Date: Tue, 20 Oct 2026 23:49:10 +0000 Subject: [PATCH 2/2] fix: avoids back loop between profile and connections The connections back arrow pushed the profile onto history, so going back from that profile returned to connections again. It now goes back through history, falling back to the profile when there is none. --- resources/js/hooks/use-go-back.ts | 10 ++++++++-- resources/js/pages/user/connections.tsx | 9 ++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/resources/js/hooks/use-go-back.ts b/resources/js/hooks/use-go-back.ts index 6df81764f..1a189889a 100644 --- a/resources/js/hooks/use-go-back.ts +++ b/resources/js/hooks/use-go-back.ts @@ -1,8 +1,11 @@ +import type { InertiaLinkProps } from '@inertiajs/react'; import { router, usePage } from '@inertiajs/react'; import LogController from '@/actions/App/Http/Controllers/LogController'; import { home } from '@/routes'; -export function useGoBack(): () => void { +export function useGoBack( + fallback?: NonNullable, +): () => void { const { auth } = usePage().props; return () => { @@ -12,6 +15,9 @@ export function useGoBack(): () => void { return; } - router.visit(auth.log === null ? home() : LogController.show(auth.log)); + router.visit( + fallback ?? + (auth.log === null ? home() : LogController.show(auth.log)), + ); }; } diff --git a/resources/js/pages/user/connections.tsx b/resources/js/pages/user/connections.tsx index 799f89a5b..b102ece4b 100644 --- a/resources/js/pages/user/connections.tsx +++ b/resources/js/pages/user/connections.tsx @@ -8,6 +8,7 @@ import { FollowButton } from '@/components/follow-button'; import { PageTabs } from '@/components/page-tabs'; import { Spinner } from '@/components/ui/spinner'; import { UserAvatar } from '@/components/user-avatar'; +import { useGoBack } from '@/hooks/use-go-back'; import AppLayout from '@/layouts/app-layout'; import { laneColor } from '@/lib/utils'; import { show } from '@/routes/user'; @@ -40,6 +41,7 @@ export default function Connections({ }) { const { auth } = usePage().props; const title = type === 'following' ? 'Following' : 'Followers'; + const goBack = useGoBack(show(user)); return ( <> @@ -47,13 +49,14 @@ export default function Connections({

- - +

{user.name}