fix: replace to invalidate context

This commit is contained in:
Aslam H
2024-10-30 05:40:38 +07:00
parent fcffba23f1
commit 5294ade0ab
7 changed files with 20 additions and 9 deletions

View File

@@ -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>

View File

@@ -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 {