diff --git a/web/app/components/sidebar/partials/profile-section.tsx b/web/app/components/sidebar/partials/profile-section.tsx index 0e02cbc6..a7297fc2 100644 --- a/web/app/components/sidebar/partials/profile-section.tsx +++ b/web/app/components/sidebar/partials/profile-section.tsx @@ -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} /> diff --git a/web/app/components/sidebar/sidebar.tsx b/web/app/components/sidebar/sidebar.tsx index b829eac4..f0815b2d 100644 --- a/web/app/components/sidebar/sidebar.tsx +++ b/web/app/components/sidebar/sidebar.tsx @@ -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 { diff --git a/web/app/routes/_layout/(auth)/_auth.tsx b/web/app/routes/_layout/(auth)/_auth.tsx index 6a00b686..4c90fe89 100644 --- a/web/app/routes/_layout/(auth)/_auth.tsx +++ b/web/app/routes/_layout/(auth)/_auth.tsx @@ -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 }) } }, diff --git a/web/app/routes/_layout/_pages/(topic)/-header.tsx b/web/app/routes/_layout/_pages/(topic)/-header.tsx index 9fe67e36..6b410235 100644 --- a/web/app/routes/_layout/_pages/(topic)/-header.tsx +++ b/web/app/routes/_layout/_pages/(topic)/-header.tsx @@ -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, }) } diff --git a/web/app/routes/_layout/_pages/(topic)/-item.tsx b/web/app/routes/_layout/_pages/(topic)/-item.tsx index 9a84a376..83e4fca6 100644 --- a/web/app/routes/_layout/_pages/(topic)/-item.tsx +++ b/web/app/routes/_layout/_pages/(topic)/-item.tsx @@ -77,7 +77,7 @@ export const LinkItem = React.memo( (learningState: LearningStateValue) => { if (!personalLinks || !me || me?._type === "Anonymous") { return clerk.redirectToSignIn({ - redirectUrl: pathname, + signInFallbackRedirectUrl: pathname, }) } diff --git a/web/app/routes/_layout/_pages/_protected/links/-link-form.tsx b/web/app/routes/_layout/_pages/_protected/links/-link-form.tsx index 94a58eca..4150bc33 100644 --- a/web/app/routes/_layout/_pages/_protected/links/-link-form.tsx +++ b/web/app/routes/_layout/_pages/_protected/links/-link-form.tsx @@ -173,7 +173,6 @@ export const LinkForm: React.FC = ({ ref.current?.contains(event.target as Node), ) ) { - console.log("clicking outside") onClose?.() } }) diff --git a/web/shared/editor/hooks/use-la-editor.ts b/web/shared/editor/hooks/use-la-editor.ts index e9ff2713..93fdd456 100644 --- a/web/shared/editor/hooks/use-la-editor.ts +++ b/web/shared/editor/hooks/use-la-editor.ts @@ -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, + }) }) }, }),