minor updates and new providers
This commit is contained in:
@@ -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]);
|
||||
|
||||
@@ -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
|
||||
]
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user