Skip to content
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
6 changes: 6 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ const ReleasePreviewPage = lazyImport(() => import("@/pages/preview-release"))
const OrganizationSettingsPage = lazyImport(
() => import("@/pages/organization-settings"),
)
const SettingsRedirectPage = lazyImport(
() => import("@/pages/settings-redirect"),
)

class ErrorBoundary extends React.Component<
{ children: React.ReactNode },
Expand Down Expand Up @@ -267,6 +270,9 @@ function App() {
{/* Organization creation route */}
<Route path="/orgs/new" component={CreateOrganizationPage} />

{/* User settings redirect */}
<Route path="/settings" component={SettingsRedirectPage} />

{/* Organization settings route */}
<Route
path="/:orgname/settings"
Expand Down
2 changes: 1 addition & 1 deletion src/components/HeaderLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const HeaderLogin = () => {
</DropdownMenuItem>
<DropdownMenuItem asChild>
<Link
href="/settings"
href={`/${session?.github_username}/settings`}
className="cursor-pointer"
onClick={() => setIsOpen(false)}
>
Expand Down
44 changes: 44 additions & 0 deletions src/pages/settings-redirect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { useEffect, useState } from "react"
import { Redirect } from "wouter"

import { FullPageLoader } from "@/App"
import { useGlobalStore } from "@/hooks/use-global-store"

const SettingsRedirectPage = () => {
const session = useGlobalStore((state) => state.session)
const [hasHydrated, setHasHydrated] = useState(() => {
if (typeof window === "undefined") return false
return useGlobalStore.persist?.hasHydrated?.() ?? false
})

useEffect(() => {
if (typeof window === "undefined") return

if (useGlobalStore.persist?.hasHydrated?.()) {
setHasHydrated(true)
return
}

const unsubFinishHydration = useGlobalStore.persist?.onFinishHydration?.(
() => {
setHasHydrated(true)
},
)

return () => {
unsubFinishHydration?.()
}
}, [])

if (!hasHydrated) {
return <FullPageLoader />
}

if (!session?.github_username) {
return <Redirect to="/" />
}

return <Redirect to={`/${session.github_username}/settings`} />
}

export default SettingsRedirectPage
Comment on lines +1 to +44
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File naming inconsistency: The file settings-redirect.tsx uses kebab-case but does not match the exported component name SettingsRedirectPage. Fix by either:

  1. Renaming the file to SettingsRedirectPage.tsx to match the export name, or
  2. Renaming the export to SettingsRedirect to align with the kebab-case file name

Consistent naming conventions improve code maintainability and follow established project patterns.

Suggested change
import { useEffect, useState } from "react"
import { Redirect } from "wouter"
import { FullPageLoader } from "@/App"
import { useGlobalStore } from "@/hooks/use-global-store"
const SettingsRedirectPage = () => {
const session = useGlobalStore((state) => state.session)
const [hasHydrated, setHasHydrated] = useState(() => {
if (typeof window === "undefined") return false
return useGlobalStore.persist?.hasHydrated?.() ?? false
})
useEffect(() => {
if (typeof window === "undefined") return
if (useGlobalStore.persist?.hasHydrated?.()) {
setHasHydrated(true)
return
}
const unsubFinishHydration = useGlobalStore.persist?.onFinishHydration?.(
() => {
setHasHydrated(true)
},
)
return () => {
unsubFinishHydration?.()
}
}, [])
if (!hasHydrated) {
return <FullPageLoader />
}
if (!session?.github_username) {
return <Redirect to="/" />
}
return <Redirect to={`/${session.github_username}/settings`} />
}
export default SettingsRedirectPage
import { useEffect, useState } from "react"
import { Redirect } from "wouter"
import { FullPageLoader } from "@/App"
import { useGlobalStore } from "@/hooks/use-global-store"
const SettingsRedirect = () => {
const session = useGlobalStore((state) => state.session)
const [hasHydrated, setHasHydrated] = useState(() => {
if (typeof window === "undefined") return false
return useGlobalStore.persist?.hasHydrated?.() ?? false
})
useEffect(() => {
if (typeof window === "undefined") return
if (useGlobalStore.persist?.hasHydrated?.()) {
setHasHydrated(true)
return
}
const unsubFinishHydration = useGlobalStore.persist?.onFinishHydration?.(
() => {
setHasHydrated(true)
},
)
return () => {
unsubFinishHydration?.()
}
}, [])
if (!hasHydrated) {
return <FullPageLoader />
}
if (!session?.github_username) {
return <Redirect to="/" />
}
return <Redirect to={`/${session.github_username}/settings`} />
}
export default SettingsRedirect

Spotted by Diamond (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.