11"use client" ;
22
33import { authClient } from "@/lib/auth-client" ;
4- import { usePathname } from "next/navigation" ;
4+ import { usePathname , useRouter } from "next/navigation" ;
55import { useEffect } from "react" ;
66
77export function AutoAnonymousLogin ( ) {
@@ -18,6 +18,7 @@ export function AutoAnonymousLogin() {
1818export function AccountMenu ( ) {
1919 const { data : session , isPending } = authClient . useSession ( ) ;
2020 const pathname = usePathname ( ) ;
21+ const router = useRouter ( ) ;
2122
2223 const signout = ( ) => {
2324 if (
@@ -27,7 +28,7 @@ export function AccountMenu() {
2728 ) {
2829 authClient . signOut ( {
2930 fetchOptions : {
30- onSuccess : ( ) => window . location . reload ( ) ,
31+ onSuccess : ( ) => router . refresh ( ) ,
3132 } ,
3233 } ) ;
3334 }
@@ -36,7 +37,7 @@ export function AccountMenu() {
3637 if ( window . confirm ( "チャット履歴は削除され、アクセスできなくなります。" ) ) {
3738 authClient . signOut ( {
3839 fetchOptions : {
39- onSuccess : ( ) => window . location . reload ( ) ,
40+ onSuccess : ( ) => router . refresh ( ) ,
4041 } ,
4142 } ) ;
4243 }
@@ -102,7 +103,7 @@ export function AccountMenu() {
102103 onClick = { ( ) =>
103104 authClient . signIn . social ( {
104105 provider : "github" ,
105- callbackURL : pathname ,
106+ callbackURL : `/clear-cache?redirect= ${ encodeURIComponent ( pathname ) } ` ,
106107 } )
107108 }
108109 >
@@ -114,7 +115,7 @@ export function AccountMenu() {
114115 onClick = { ( ) =>
115116 authClient . signIn . social ( {
116117 provider : "google" ,
117- callbackURL : pathname ,
118+ callbackURL : `/clear-cache?redirect= ${ encodeURIComponent ( pathname ) } ` ,
118119 } )
119120 }
120121 >
0 commit comments