minor updates and new providers

This commit is contained in:
RoyceDa
2026-01-31 03:02:42 +02:00
parent 2ab86b8df3
commit bcb7e917da
5 changed files with 90 additions and 56 deletions

View File

@@ -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,9 +52,11 @@ export default function App() {
return (
<InformationProvider>
<DialogStateProvider>
<DeviceProvider>
<DialogListProvider>
<BlacklistProvider>
<SettingsProvider>
<SystemAccountProvider>
<Box h={'100%'}>
<Topbar></Topbar>
<Divider color={colors.borderColor}></Divider>
@@ -74,9 +78,11 @@ export default function App() {
</ImageViwerProvider>
</ContextMenuProvider>
</Box>
</SystemAccountProvider>
</SettingsProvider>
</BlacklistProvider>
</DialogListProvider>
</DeviceProvider>
</DialogStateProvider>
</InformationProvider>
);

View File

@@ -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)){
/**
* Если мы были упомянуты в этом диалоге, то убираем упоминание,

View File

@@ -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]);

View File

@@ -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
]
}

View File

@@ -9,8 +9,8 @@ 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
@@ -22,17 +22,16 @@ createRoot(document.getElementById('app') as HTMLElement).render(
<AccountProvder>
<ModalsProvider>
<MemoryProvider>
<DeviceProvider>
<HashRouter>
<SystemProvider>
<ProtocolProvider serverAddress={selectServer()}>
<App />
</ProtocolProvider>
</SystemProvider>
</HashRouter>
</DeviceProvider>
</MemoryProvider>
</ModalsProvider>
</AccountProvder>
</DatabaseProvider>
</MantineProvider>
)