23 lines
815 B
TypeScript
23 lines
815 B
TypeScript
import { useDatabase } from "@/app/providers/DatabaseProvider/useDatabase";
|
|
import { UserInformation } from "./InformationProvider";
|
|
import { OnlineState } from "../ProtocolProvider/protocol/packets/packet.onlinestate";
|
|
|
|
export function useUserCacheFunc() {
|
|
const {getQuery} = useDatabase();
|
|
|
|
const getUserInformation = async (publicKey: string): Promise<UserInformation | null> => {
|
|
const result = await getQuery("SELECT * FROM `cached_users` WHERE `public_key` = ?", [publicKey]);
|
|
if(!result){
|
|
return null;
|
|
}
|
|
return {
|
|
publicKey: result.public_key,
|
|
verified: result.verified,
|
|
title: result.title,
|
|
username: result.username,
|
|
online: OnlineState.OFFLINE
|
|
};
|
|
}
|
|
|
|
return getUserInformation;
|
|
} |