From f6277bcc83d8306c5ca9c8fc269cea6b7760c004 Mon Sep 17 00:00:00 2001 From: molvqingtai Date: Mon, 23 Sep 2024 03:16:44 +0800 Subject: [PATCH] fix(setup): setup page display timing is incorrect --- src/app/content/App.tsx | 24 ++++- src/app/content/index.tsx | 2 +- src/app/content/views/Setup/index.tsx | 9 +- src/domain/Room.ts | 150 +++++++++++++++----------- src/domain/UserInfo.ts | 35 +++--- src/domain/modules/Status.ts | 102 ++++++++++++++++++ src/lib/uglyAvatar/index.js | 130 +++++++++++++++++++++- 7 files changed, 362 insertions(+), 90 deletions(-) create mode 100644 src/domain/modules/Status.ts diff --git a/src/app/content/App.tsx b/src/app/content/App.tsx index 79f9b67..b484e34 100644 --- a/src/app/content/App.tsx +++ b/src/app/content/App.tsx @@ -9,6 +9,8 @@ import { stringToHex } from '@/utils' import { Toaster } from '@/components/ui/Sonner' import UserInfoDomain from '@/domain/UserInfo' import Setup from '@/app/content/views/Setup' +import MessageListDomain from '@/domain/MessageList' +import { useEffect } from 'react' const hostRoomId = stringToHex(document.location.host) @@ -16,15 +18,31 @@ export default function App() { const send = useRemeshSend() const roomDomain = useRemeshDomain(RoomDomain()) const userInfoDomain = useRemeshDomain(UserInfoDomain()) - send(roomDomain.command.JoinRoomCommand(hostRoomId)) - const isLogin = useRemeshQuery(userInfoDomain.query.IsLoginQuery()) + const messageListDomain = useRemeshDomain(MessageListDomain()) + const joinRoomFinished = useRemeshQuery(roomDomain.query.IsFinishedQuery()) + const userInfoFinished = useRemeshQuery(userInfoDomain.query.IsFinishedQuery()) + + const userInfo = useRemeshQuery(userInfoDomain.query.UserInfoQuery()) + + const notUserInfo = userInfoFinished && !userInfo + + useEffect(() => { + if (userInfoFinished) { + if (userInfo) { + !joinRoomFinished && send(roomDomain.command.JoinRoomCommand(hostRoomId)) + } else { + send(messageListDomain.command.ClearListCommand()) + } + } + }, [userInfoFinished, userInfo, joinRoomFinished]) + return ( <>