File tree Expand file tree Collapse file tree 5 files changed +17
-15
lines changed
apps/dashboard/src/app/nebula-app/(app) Expand file tree Collapse file tree 5 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -66,17 +66,13 @@ export function ChatPageContent(props: {
6666 // update page URL without reloading
6767 window . history . replaceState ( { } , "" , `/chat/${ sessionId } ` ) ;
6868
69- const url = new URL ( window . location . origin ) ;
70-
7169 // if the current page is landing page, link to /chat
7270 // if current page is new /chat page, link to landing page
7371 if ( props . type === "landing" ) {
74- url . pathname = "/chat" ;
72+ newChatPageUrlStore . setValue ( "/chat" ) ;
7573 } else {
76- url . pathname = "/" ;
74+ newChatPageUrlStore . setValue ( "/" ) ;
7775 }
78-
79- newChatPageUrlStore . setValue ( url . href ) ;
8076 }
8177
8278 const messagesEndRef = useRef < HTMLDivElement > ( null ) ;
Original file line number Diff line number Diff line change 11"use client" ;
22import { ScrollShadow } from "@/components/ui/ScrollShadow/ScrollShadow" ;
33import { Button } from "@/components/ui/button" ;
4- import { useStore } from "@/lib/reactive" ;
54import type { Account } from "@3rdweb-sdk/react/hooks/useApi" ;
65import { ChevronRightIcon , MessageSquareDashedIcon } from "lucide-react" ;
76import Link from "next/link" ;
87import type { TruncatedSessionInfo } from "../api/types" ;
8+ import { useNewChatPageLink } from "../hooks/useNewChatPageLink" ;
99import { useSessionsWithLocalOverrides } from "../hooks/useSessionsWithLocalOverrides" ;
1010import { NebulaIcon } from "../icons/NebulaIcon" ;
11- import { newChatPageUrlStore } from "../stores" ;
1211import { ChatSidebarLink } from "./ChatSidebarLink" ;
1312import { NebulaAccountButton } from "./NebulaAccountButton" ;
1413
@@ -80,8 +79,3 @@ export function ChatSidebar(props: {
8079 </ div >
8180 ) ;
8281}
83-
84- export function useNewChatPageLink ( ) {
85- const newChatPage = useStore ( newChatPageUrlStore ) ;
86- return newChatPage || "/chat" ;
87- }
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { EllipsisIcon, TrashIcon } from "lucide-react";
1414import { usePathname } from "next/navigation" ;
1515import { toast } from "sonner" ;
1616import { deleteSession } from "../api/session" ;
17+ import { useNewChatPageLink } from "../hooks/useNewChatPageLink" ;
1718import { deletedSessionsStore } from "../stores" ;
1819
1920// TODO - add delete chat confirmation dialog
@@ -27,6 +28,7 @@ export function ChatSidebarLink(props: {
2728 const pathname = usePathname ( ) ;
2829 const linkPath = `/chat/${ props . sessionId } ` ;
2930 const isDeletingCurrentPage = pathname === linkPath ;
31+ const newChatLink = useNewChatPageLink ( ) ;
3032 const deleteChat = useMutation ( {
3133 mutationFn : ( ) => {
3234 return deleteSession ( {
@@ -38,7 +40,7 @@ export function ChatSidebarLink(props: {
3840 const prev = deletedSessionsStore . getValue ( ) ;
3941 deletedSessionsStore . setValue ( [ ...prev , props . sessionId ] ) ;
4042 if ( isDeletingCurrentPage ) {
41- router . replace ( "/" ) ;
43+ router . replace ( newChatLink ) ;
4244 }
4345 } ,
4446 } ) ;
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import { MenuIcon } from "lucide-react";
1212import Link from "next/link" ;
1313import { useState } from "react" ;
1414import type { TruncatedSessionInfo } from "../api/types" ;
15- import { ChatSidebar , useNewChatPageLink } from "./ChatSidebar" ;
15+ import { useNewChatPageLink } from "../hooks/useNewChatPageLink" ;
16+ import { ChatSidebar } from "./ChatSidebar" ;
1617
1718export function MobileNav ( props : {
1819 sessions : TruncatedSessionInfo [ ] ;
Original file line number Diff line number Diff line change 1+ "use client" ;
2+
3+ import { useStore } from "@/lib/reactive" ;
4+ import { newChatPageUrlStore } from "../stores" ;
5+
6+ export function useNewChatPageLink ( ) {
7+ const newChatPage = useStore ( newChatPageUrlStore ) ;
8+ return newChatPage || "/chat" ;
9+ }
You can’t perform that action at this time.
0 commit comments