File tree 5 files changed +17
-15
lines changed
apps/dashboard/src/app/nebula-app/(app) 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: {
66
66
// update page URL without reloading
67
67
window . history . replaceState ( { } , "" , `/chat/${ sessionId } ` ) ;
68
68
69
- const url = new URL ( window . location . origin ) ;
70
-
71
69
// if the current page is landing page, link to /chat
72
70
// if current page is new /chat page, link to landing page
73
71
if ( props . type === "landing" ) {
74
- url . pathname = "/chat" ;
72
+ newChatPageUrlStore . setValue ( "/chat" ) ;
75
73
} else {
76
- url . pathname = "/" ;
74
+ newChatPageUrlStore . setValue ( "/" ) ;
77
75
}
78
-
79
- newChatPageUrlStore . setValue ( url . href ) ;
80
76
}
81
77
82
78
const messagesEndRef = useRef < HTMLDivElement > ( null ) ;
Original file line number Diff line number Diff line change 1
1
"use client" ;
2
2
import { ScrollShadow } from "@/components/ui/ScrollShadow/ScrollShadow" ;
3
3
import { Button } from "@/components/ui/button" ;
4
- import { useStore } from "@/lib/reactive" ;
5
4
import type { Account } from "@3rdweb-sdk/react/hooks/useApi" ;
6
5
import { ChevronRightIcon , MessageSquareDashedIcon } from "lucide-react" ;
7
6
import Link from "next/link" ;
8
7
import type { TruncatedSessionInfo } from "../api/types" ;
8
+ import { useNewChatPageLink } from "../hooks/useNewChatPageLink" ;
9
9
import { useSessionsWithLocalOverrides } from "../hooks/useSessionsWithLocalOverrides" ;
10
10
import { NebulaIcon } from "../icons/NebulaIcon" ;
11
- import { newChatPageUrlStore } from "../stores" ;
12
11
import { ChatSidebarLink } from "./ChatSidebarLink" ;
13
12
import { NebulaAccountButton } from "./NebulaAccountButton" ;
14
13
@@ -80,8 +79,3 @@ export function ChatSidebar(props: {
80
79
</ div >
81
80
) ;
82
81
}
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";
14
14
import { usePathname } from "next/navigation" ;
15
15
import { toast } from "sonner" ;
16
16
import { deleteSession } from "../api/session" ;
17
+ import { useNewChatPageLink } from "../hooks/useNewChatPageLink" ;
17
18
import { deletedSessionsStore } from "../stores" ;
18
19
19
20
// TODO - add delete chat confirmation dialog
@@ -27,6 +28,7 @@ export function ChatSidebarLink(props: {
27
28
const pathname = usePathname ( ) ;
28
29
const linkPath = `/chat/${ props . sessionId } ` ;
29
30
const isDeletingCurrentPage = pathname === linkPath ;
31
+ const newChatLink = useNewChatPageLink ( ) ;
30
32
const deleteChat = useMutation ( {
31
33
mutationFn : ( ) => {
32
34
return deleteSession ( {
@@ -38,7 +40,7 @@ export function ChatSidebarLink(props: {
38
40
const prev = deletedSessionsStore . getValue ( ) ;
39
41
deletedSessionsStore . setValue ( [ ...prev , props . sessionId ] ) ;
40
42
if ( isDeletingCurrentPage ) {
41
- router . replace ( "/" ) ;
43
+ router . replace ( newChatLink ) ;
42
44
}
43
45
} ,
44
46
} ) ;
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import { MenuIcon } from "lucide-react";
12
12
import Link from "next/link" ;
13
13
import { useState } from "react" ;
14
14
import type { TruncatedSessionInfo } from "../api/types" ;
15
- import { ChatSidebar , useNewChatPageLink } from "./ChatSidebar" ;
15
+ import { useNewChatPageLink } from "../hooks/useNewChatPageLink" ;
16
+ import { ChatSidebar } from "./ChatSidebar" ;
16
17
17
18
export function MobileNav ( props : {
18
19
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