mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
fix: replace to invalidate context
This commit is contained in:
@@ -16,11 +16,12 @@ import { cn } from "@/lib/utils"
|
||||
import { showShortcutAtom } from "@/components/shortcut/shortcut"
|
||||
import { useKeyboardManager } from "@/hooks/use-keyboard-manager"
|
||||
import { SignInButton, useAuth, useUser } from "@clerk/tanstack-start"
|
||||
import { Link, useLocation } from "@tanstack/react-router"
|
||||
import { Link, useLocation, useRouter } from "@tanstack/react-router"
|
||||
import { ShortcutKey } from "@shared/minimal-tiptap/components/shortcut-key"
|
||||
import { Feedback } from "./feedback"
|
||||
|
||||
export const ProfileSection: React.FC = () => {
|
||||
const router = useRouter()
|
||||
const { user, isSignedIn } = useUser()
|
||||
const { signOut } = useAuth()
|
||||
const [menuOpen, setMenuOpen] = React.useState(false)
|
||||
@@ -29,6 +30,15 @@ export const ProfileSection: React.FC = () => {
|
||||
|
||||
const { disableKeydown } = useKeyboardManager("profileSection")
|
||||
|
||||
const handleSignOut = async () => {
|
||||
// this is no good, stupid fn, invalidate context but dont do it correctly
|
||||
await router.invalidate()
|
||||
|
||||
signOut(() => {
|
||||
window.location.replace("/")
|
||||
})
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
disableKeydown(menuOpen)
|
||||
}, [menuOpen, disableKeydown])
|
||||
@@ -53,7 +63,7 @@ export const ProfileSection: React.FC = () => {
|
||||
user={user}
|
||||
menuOpen={menuOpen}
|
||||
setMenuOpen={setMenuOpen}
|
||||
signOut={signOut}
|
||||
signOut={handleSignOut}
|
||||
setShowShortcut={setShowShortcut}
|
||||
/>
|
||||
<span className="flex flex-auto"></span>
|
||||
|
||||
@@ -8,11 +8,10 @@ import { useAccountOrGuest } from "@/lib/providers/jazz-provider"
|
||||
import { LaIcon } from "@/components/custom/la-icon"
|
||||
import { Link, useLocation } from "@tanstack/react-router"
|
||||
|
||||
// import { LinkSection } from "./partials/link-section"
|
||||
import { PageSection } from "./partials/page-section"
|
||||
import { ProfileSection } from "./partials/profile-section"
|
||||
import { JournalSection } from "./partials/journal-section"
|
||||
import { TaskSection } from "./partials/task-section"
|
||||
// import { TaskSection } from "./partials/task-section"
|
||||
import { LinkCollection } from "./partials/link-collection"
|
||||
|
||||
interface SidebarContextType {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { createFileRoute, Outlet, redirect } from "@tanstack/react-router"
|
||||
|
||||
export const Route = createFileRoute("/_layout/(auth)/_auth")({
|
||||
beforeLoad({ context }) {
|
||||
if (context.auth.userId) {
|
||||
if (context.auth?.userId) {
|
||||
throw redirect({ to: "/links", replace: true })
|
||||
}
|
||||
},
|
||||
|
||||
@@ -89,7 +89,7 @@ export const TopicDetailHeader = React.memo(function TopicDetailHeader({
|
||||
const handleAddToProfile = (learningState: LearningStateValue) => {
|
||||
if (me?._type === "Anonymous") {
|
||||
return clerk.redirectToSignIn({
|
||||
redirectUrl: pathname,
|
||||
signInFallbackRedirectUrl: pathname,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ export const LinkItem = React.memo(
|
||||
(learningState: LearningStateValue) => {
|
||||
if (!personalLinks || !me || me?._type === "Anonymous") {
|
||||
return clerk.redirectToSignIn({
|
||||
redirectUrl: pathname,
|
||||
signInFallbackRedirectUrl: pathname,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,6 @@ export const LinkForm: React.FC<LinkFormProps> = ({
|
||||
ref.current?.contains(event.target as Node),
|
||||
)
|
||||
) {
|
||||
console.log("clicking outside")
|
||||
onClose?.()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -190,7 +190,10 @@ const createExtensions = ({
|
||||
},
|
||||
onValidationError: (errors) => {
|
||||
errors.forEach((error) => {
|
||||
console.log("File validation error", error)
|
||||
toast.error("Image validation error", {
|
||||
position: "bottom-right",
|
||||
description: error.reason,
|
||||
})
|
||||
})
|
||||
},
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user