diff --git a/client/ui/App.tsx b/client/ui/App.tsx index d843f33..0f05267 100644 --- a/client/ui/App.tsx +++ b/client/ui/App.tsx @@ -34,8 +34,6 @@ declare global { } export default function App() { - const [recentsList, setRecentsList] = React.useState([] as RecentChat[]) - const [navigationItemSelected, setNavigationItemSelected] = React.useState('Recents') const navigationRailRef = React.useRef(null) @@ -57,7 +55,7 @@ export default function App() { useEventListener(openMyProfileDialogButtonRef, 'click', (_event) => { myProfileDialogRef.current!.open = true }) - + const addContactDialogRef = React.useRef(null) const chatInfoDialogRef = React.useRef(null) @@ -91,6 +89,11 @@ export default function App() { } }) + function openChatInfoDialog(chat: Chat) { + setChatInfo(chat) + chatInfoDialogRef.current!.open = true + } + return (
- + @@ -149,16 +152,13 @@ export default function App() { setIsShowChatFragment(true) }} display={navigationItemSelected == "Recents"} - currentChatId={currentChatId} - recentsList={recentsList} - setRecentsList={setRecentsList} /> + currentChatId={currentChatId} /> } { // 對話列表 }
@@ -181,6 +181,7 @@ export default function App() { { isShowChatFragment && } diff --git a/client/ui/AppMobile.tsx b/client/ui/AppMobile.tsx index f5c56c7..c6f3093 100644 --- a/client/ui/AppMobile.tsx +++ b/client/ui/AppMobile.tsx @@ -33,8 +33,6 @@ declare global { } export default function AppMobile() { - const [recentsList, setRecentsList] = React.useState([] as RecentChat[]) - const [navigationItemSelected, setNavigationItemSelected] = React.useState('Recents') const navigationBarRef = React.useRef(null) @@ -56,7 +54,7 @@ export default function AppMobile() { useEventListener(openMyProfileDialogButtonRef, 'click', (_event) => { myProfileDialogRef.current!.open = true }) - + const addContactDialogRef = React.useRef(null) const chatInfoDialogRef = React.useRef(null) @@ -93,6 +91,11 @@ export default function AppMobile() { } }) + function openChatInfoDialog(chat: Chat) { + setChatInfo(chat) + chatInfoDialogRef.current!.open = true + } + return (
setIsShowChatFragment(false)} key={currentChatId} + openChatInfoDialog={openChatInfoDialog} target={currentChatId} />
@@ -142,7 +146,7 @@ export default function AppMobile() { setIsShowChatFragment(true) }} chat={chatInfo} /> - + @@ -183,16 +187,13 @@ export default function AppMobile() { setIsShowChatFragment(true) }} display={navigationItemSelected == "Recents"} - currentChatId={currentChatId} - recentsList={recentsList} - setRecentsList={setRecentsList} /> + currentChatId={currentChatId} /> } { // 對話列表 } diff --git a/client/ui/main/ContactsList.tsx b/client/ui/main/ContactsList.tsx index 851b07b..c7005bc 100644 --- a/client/ui/main/ContactsList.tsx +++ b/client/ui/main/ContactsList.tsx @@ -11,15 +11,13 @@ import EventBus from "../../EventBus.ts" interface Args extends React.HTMLAttributes { display: boolean - chatInfoDialogRef: React.MutableRefObject + openChatInfoDialog: (chat: Chat) => void addContactDialogRef: React.MutableRefObject - setChatInfo: React.Dispatch> } export default function ContactsList({ display, - setChatInfo, - chatInfoDialogRef, + openChatInfoDialog, addContactDialogRef, ...props }: Args) { @@ -84,8 +82,7 @@ export default function ContactsList({ /*if (isMultiSelecting) self.active = !self.active else*/ - setChatInfo(v) - chatInfoDialogRef.current!.open = true + openChatInfoDialog(v) }} key={v.id} contact={v} />