From bcb7e917dabfa73cfa447ab154e47215a542a2c0 Mon Sep 17 00:00:00 2001 From: RoyceDa Date: Sat, 31 Jan 2026 03:02:42 +0200 Subject: [PATCH] minor updates and new providers --- app/App.tsx | 60 ++++++++++--------- .../DialogProvider/DialogProvider.tsx | 2 +- .../InformationProvider.tsx | 7 +++ .../InformationProvider/useUserInformation.ts | 38 +++++++++--- app/renderer.tsx | 39 ++++++------ 5 files changed, 90 insertions(+), 56 deletions(-) diff --git a/app/App.tsx b/app/App.tsx index 846e02c..5087969 100644 --- a/app/App.tsx +++ b/app/App.tsx @@ -21,6 +21,8 @@ import { SettingsProvider } from './providers/SettingsProvider/SettingsProvider' import { DialogListProvider } from './providers/DialogListProvider/DialogListProvider'; import { DialogStateProvider } from './providers/DialogStateProvider.tsx/DialogStateProvider'; import { DeviceConfirm } from './views/DeviceConfirm/DeviceConfirm'; +import { SystemAccountProvider } from './providers/SystemAccountsProvider/SystemAccountsProvider'; +import { DeviceProvider } from './providers/DeviceProvider/DeviceProvider'; window.Buffer = Buffer; export default function App() { @@ -50,33 +52,37 @@ export default function App() { return ( - - - - - - - - - - - - } /> - } /> - } /> - } /> - } /> - } /> - - - - - - - - + + + + + + + + + + + + + + } /> + } /> + } /> + } /> + } /> + } /> + + + + + + + + + + ); diff --git a/app/providers/DialogProvider/DialogProvider.tsx b/app/providers/DialogProvider/DialogProvider.tsx index ae649c8..0dccaa9 100644 --- a/app/providers/DialogProvider/DialogProvider.tsx +++ b/app/providers/DialogProvider/DialogProvider.tsx @@ -206,7 +206,6 @@ export function DialogProvider(props: DialogProviderProps) { * Если сообщение не от меня и не групповое, * расшифровываем ключ чачи своим приватным ключом */ - console.info("Decrypting chacha key for message"); decryptKey = Buffer.from(await decrypt(message.chacha_key, privatePlain), "binary").toString('utf-8'); } finalMessages.push({ @@ -222,6 +221,7 @@ export function DialogProvider(props: DialogProviderProps) { message_id: message.message_id, attachments: await loadAttachments(message.attachments) }); + if(isMentioned(props.dialog)){ /** * Если мы были упомянуты в этом диалоге, то убираем упоминание, diff --git a/app/providers/InformationProvider/InformationProvider.tsx b/app/providers/InformationProvider/InformationProvider.tsx index a5538f9..9f8a12f 100644 --- a/app/providers/InformationProvider/InformationProvider.tsx +++ b/app/providers/InformationProvider/InformationProvider.tsx @@ -125,6 +125,13 @@ export function InformationProvider(props: InformationProviderProps) { } const updateUserInformation = async (userInfo : UserInformation) => { + if(systemAccounts.find((acc) => acc.publicKey == userInfo.publicKey)){ + /** + * Данные системных аккаунтов не нужно кэшифровать, они уже + * прописаны в коде + */ + return; + } const result = await getQuery("SELECT COUNT(*) as count FROM cached_users WHERE public_key = ?", [userInfo.publicKey]); if (result.count > 0) { await runQuery(`UPDATE cached_users SET title = ?, username = ?, verified = ? WHERE public_key = ?`, [userInfo.title, userInfo.username, userInfo.verified, userInfo.publicKey]); diff --git a/app/providers/InformationProvider/useUserInformation.ts b/app/providers/InformationProvider/useUserInformation.ts index bc568e5..d8b58ce 100644 --- a/app/providers/InformationProvider/useUserInformation.ts +++ b/app/providers/InformationProvider/useUserInformation.ts @@ -66,6 +66,12 @@ export function useUserInformation(publicKey: string) : [ * Подписываемся на статус пользователя онлайн или не онлайн * если еще не подписаны */ + if(systemAccounts.find((acc) => acc.publicKey == publicKey)){ + /** + * У системных аккаунтов не нужно подписыаться на онлайн статус + */ + return; + } if(onlineSubscribes.indexOf(publicKey) !== -1 || publicKey.indexOf("#group:") !== -1 || publicKey == ownPublicKey @@ -81,12 +87,19 @@ export function useUserInformation(publicKey: string) : [ subscribePacket.addPublicKey(publicKey); send(subscribePacket); setOnlineSubscribes((prev) => [...prev, publicKey]); - }, [blocked]); + }, [blocked, publicKey]); useEffect(() => { if(user || publicKey.trim() == ''){ return; } + if(systemAccounts.find((acc) => acc.publicKey == publicKey)){ + /** + * System account has no updates, its hardcoded display + * name and user name + */ + return; + } setLoading(true); let packetSearch = new PacketSearch(); packetSearch.setSearch(publicKey); @@ -119,14 +132,23 @@ export function useUserInformation(publicKey: string) : [ } }, [publicKey, privateKey]); + let userInfo = user ? user : { + title: "DELETED", + username: "", + publicKey: "", + online: OnlineState.OFFLINE, + verified: 0 + }; + + if(systemAccounts.find((acc) => acc.publicKey == publicKey)){ + /** + * Это системный аккаунт, возвращаем его информацию + */ + userInfo = systemAccounts.find((acc) => acc.publicKey == publicKey)!; + } + return [ - { - title: user ? user.title : "DELETED", - username: user ? user.username : "", - publicKey: user ? user.publicKey : "", - online: user ? user.online : OnlineState.OFFLINE, - verified: user ? user.verified : 0 - }, updateUserInformation, forceUpdateUserInformation, loading + userInfo, updateUserInformation, forceUpdateUserInformation, loading ] } \ No newline at end of file diff --git a/app/renderer.tsx b/app/renderer.tsx index 7171e70..dc65db1 100644 --- a/app/renderer.tsx +++ b/app/renderer.tsx @@ -9,30 +9,29 @@ import { AccountProvder } from './providers/AccountProvider/AccountProvider'; import { DatabaseProvider } from './providers/DatabaseProvider/DatabaseProvider'; import { ProtocolProvider } from './providers/ProtocolProvider/ProtocolProvider'; import { selectServer } from './servers'; -import { DeviceProvider } from './providers/DeviceProvider/DeviceProvider'; import { HashRouter } from 'react-router-dom'; +import { SystemProvider } from './providers/SystemProvider/SystemProvider'; const theme = createTheme({ - defaultRadius: 8 + defaultRadius: 8 }); createRoot(document.getElementById('app') as HTMLElement).render( - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + ) - \ No newline at end of file