refactor: 抽离 openChatInfoDialog
This commit is contained in:
@@ -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<NavigationBar>(null)
|
||||
@@ -56,7 +54,7 @@ export default function AppMobile() {
|
||||
useEventListener(openMyProfileDialogButtonRef, 'click', (_event) => {
|
||||
myProfileDialogRef.current!.open = true
|
||||
})
|
||||
|
||||
|
||||
const addContactDialogRef = React.useRef<Dialog>(null)
|
||||
|
||||
const chatInfoDialogRef = React.useRef<Dialog>(null)
|
||||
@@ -93,6 +91,11 @@ export default function AppMobile() {
|
||||
}
|
||||
})
|
||||
|
||||
function openChatInfoDialog(chat: Chat) {
|
||||
setChatInfo(chat)
|
||||
chatInfoDialogRef.current!.open = true
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: "flex",
|
||||
@@ -113,6 +116,7 @@ export default function AppMobile() {
|
||||
showReturnButton={true}
|
||||
onReturnButtonClicked={() => setIsShowChatFragment(false)}
|
||||
key={currentChatId}
|
||||
openChatInfoDialog={openChatInfoDialog}
|
||||
target={currentChatId} />
|
||||
</div>
|
||||
</mdui-dialog>
|
||||
@@ -142,7 +146,7 @@ export default function AppMobile() {
|
||||
setIsShowChatFragment(true)
|
||||
}}
|
||||
chat={chatInfo} />
|
||||
|
||||
|
||||
<AddContactDialog
|
||||
addContactDialogRef={addContactDialogRef} />
|
||||
|
||||
@@ -183,16 +187,13 @@ export default function AppMobile() {
|
||||
setIsShowChatFragment(true)
|
||||
}}
|
||||
display={navigationItemSelected == "Recents"}
|
||||
currentChatId={currentChatId}
|
||||
recentsList={recentsList}
|
||||
setRecentsList={setRecentsList} />
|
||||
currentChatId={currentChatId} />
|
||||
}
|
||||
{
|
||||
// 對話列表
|
||||
<ContactsList
|
||||
setChatInfo={setChatInfo}
|
||||
openChatInfoDialog={openChatInfoDialog}
|
||||
addContactDialogRef={addContactDialogRef as any}
|
||||
chatInfoDialogRef={chatInfoDialogRef as any}
|
||||
display={navigationItemSelected == "Contacts"} />
|
||||
}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user