diff --git a/client/ui/chat-fragment/ChatFragment.tsx b/client/ui/chat-fragment/ChatFragment.tsx index 9c8e013..e0d40f0 100644 --- a/client/ui/chat-fragment/ChatFragment.tsx +++ b/client/ui/chat-fragment/ChatFragment.tsx @@ -12,9 +12,10 @@ import SwitchPreference from "../preference/SwitchPreference" import TextFieldPreference from "../preference/TextFieldPreference" import * as React from 'react' import ChatMessageContainer from "./ChatMessageContainer" +import gotoChatInfo from "../routers/gotoChatInfo" -function gotoChatInfo(nav: NavigateFunction, id: string) { - nav('/chat/info?id=' + id) +function gotoChatInfo2(nav: NavigateFunction, id: string, useWithRouterChatFragment?: boolean) { + useWithRouterChatFragment ? nav('/chat/info?id=' + id) : gotoChatInfo(nav, id) } interface MduiTabFitSizeArgs extends React.HTMLAttributes { @@ -100,13 +101,13 @@ export default function ChatFragment({ marginRight: '5px', }}> { - + }} style={{ alignSelf: 'center', marginLeft: '5px', marginRight: '5px', }}> - gotoChatInfo(nav, chatInfo.getId())} style={{ + gotoChatInfo2(nav, chatInfo.getId(), openedWithRouter)} style={{ alignSelf: 'center', marginLeft: '5px', marginRight: '5px', diff --git a/client/ui/routers/RouterDialogsContext.ts b/client/ui/routers/RouterDialogsContext.ts index 6558873..f69d7fd 100644 --- a/client/ui/routers/RouterDialogsContext.ts +++ b/client/ui/routers/RouterDialogsContext.ts @@ -1,5 +1,6 @@ +import { Dialog } from 'mdui' import * as React from 'react' -const RouterDialogsContext = React.createContext(() => {}) +const RouterDialogsContext = React.createContext((ref: React.MutableRefObject) => {}) export default RouterDialogsContext diff --git a/client/ui/routers/RouterDialogsContextWrapper.tsx b/client/ui/routers/RouterDialogsContextWrapper.tsx index 20e4d6f..ca50e2e 100644 --- a/client/ui/routers/RouterDialogsContextWrapper.tsx +++ b/client/ui/routers/RouterDialogsContextWrapper.tsx @@ -4,7 +4,7 @@ import RouterDialogsContext from './RouterDialogsContext' import { BlockerFunction, useBlocker, useNavigate } from "react-router" import sleep from "../../utils/sleep" -const routerDialogsList = [] +const routerDialogsList: React.MutableRefObject[] = [] export default function RouterDialogsContextWrapper({ children }: React.HTMLAttributes) { const proceedRef = React.useRef<() => void>() @@ -41,6 +41,9 @@ export default function RouterDialogsContextWrapper({ children }: React.HTMLAttr // 这个让姐姐来就好啦 routerDialogsList.length != 0 && (routerDialogsList[routerDialogsList.length - 1].current!.open = false) } + return () => { + blocker.reset?.() + } }, [blocker.state]) // 注册