From 1f44af873c57aaed2eb3d845342ad427ce1d8a4f Mon Sep 17 00:00:00 2001 From: molvqingtai Date: Wed, 2 Oct 2024 17:57:28 +0800 Subject: [PATCH] perf: support unread status --- src/app/content/App.tsx | 41 +----- src/app/content/index.tsx | 4 +- src/app/content/views/AppButton/index.tsx | 50 +++++-- src/app/content/views/AppContainer/index.tsx | 10 +- src/app/content/views/Header/index.tsx | 2 - src/constants/config.ts | 2 +- src/domain/AppStatus.ts | 144 +++++++++++++++++++ src/domain/externs/Storage.ts | 24 ++++ src/domain/impls/Storage.ts | 17 ++- 9 files changed, 238 insertions(+), 56 deletions(-) create mode 100644 src/domain/AppStatus.ts diff --git a/src/app/content/App.tsx b/src/app/content/App.tsx index 4b00b1c..9f39ed9 100644 --- a/src/app/content/App.tsx +++ b/src/app/content/App.tsx @@ -8,22 +8,11 @@ import RoomDomain from '@/domain/Room' import UserInfoDomain from '@/domain/UserInfo' import Setup from '@/app/content/views/Setup' import MessageListDomain from '@/domain/MessageList' -import { useEffect, useRef, useState } from 'react' +import { useEffect, useRef } from 'react' import { Toaster } from 'sonner' -import { browserSyncStorage, indexDBStorage } from '@/domain/impls/Storage' -import { APP_OPEN_STATUS_STORAGE_KEY } from '@/constants/config' -import LogoIcon0 from '@/assets/images/logo-0.svg' -import LogoIcon1 from '@/assets/images/logo-1.svg' -import LogoIcon2 from '@/assets/images/logo-2.svg' -import LogoIcon3 from '@/assets/images/logo-3.svg' -import LogoIcon4 from '@/assets/images/logo-4.svg' -import LogoIcon5 from '@/assets/images/logo-5.svg' -import LogoIcon6 from '@/assets/images/logo-6.svg' -import { getDay } from 'date-fns' import DanmakuContainer from './components/DanmakuContainer' import DanmakuDomain from '@/domain/Danmaku' -import { browser } from 'wxt/browser' export default function App() { const send = useRemeshSend() @@ -32,13 +21,11 @@ export default function App() { const messageListDomain = useRemeshDomain(MessageListDomain()) const danmakuDomain = useRemeshDomain(DanmakuDomain()) const danmakuIsEnabled = useRemeshQuery(danmakuDomain.query.IsEnabledQuery()) - const userInfo = useRemeshQuery(userInfoDomain.query.UserInfoQuery()) const userInfoSetFinished = useRemeshQuery(userInfoDomain.query.UserInfoSetIsFinishedQuery()) const userInfoLoadFinished = useRemeshQuery(userInfoDomain.query.UserInfoLoadIsFinishedQuery()) const messageListLoadFinished = useRemeshQuery(messageListDomain.query.LoadIsFinishedQuery()) - const notUserInfo = userInfoLoadFinished && !userInfoSetFinished - const DayLogo = [LogoIcon0, LogoIcon1, LogoIcon2, LogoIcon3, LogoIcon4, LogoIcon5, LogoIcon6][getDay(Date())] + const notUserInfo = userInfoLoadFinished && !userInfoSetFinished useEffect(() => { if (messageListLoadFinished) { @@ -51,23 +38,6 @@ export default function App() { } }, [userInfoSetFinished, messageListLoadFinished]) - const [appOpen, setAppOpen] = useState(false) - - const handleToggleApp = async () => { - const value = !appOpen - setAppOpen(value) - await indexDBStorage.setItem(APP_OPEN_STATUS_STORAGE_KEY, value) - } - - const getAppOpenStatus = async () => { - const value = await indexDBStorage.getItem(APP_OPEN_STATUS_STORAGE_KEY) - setAppOpen(!!value) - } - - useEffect(() => { - getAppOpenStatus() - }, []) - const danmakuContainerRef = useRef(null) useEffect(() => { @@ -76,19 +46,18 @@ export default function App() { danmakuIsEnabled && send(danmakuDomain.command.DestroyCommand()) } }, [danmakuIsEnabled]) + console.log(1) return ( <> - +