update version

This commit is contained in:
PhilReact 2025-04-10 01:17:44 +03:00
parent 25b6cc43e3
commit c49993729e
2 changed files with 13 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{
"name": "qapp-core",
"version": "1.0.16",
"version": "1.0.17",
"description": "Qortal's core React library with global state, UI components, and utilities",
"main": "dist/index.js",
"module": "dist/index.mjs",

View File

@ -19,14 +19,18 @@ export type BalanceSetting =
interval?: number;
};
interface userAccountInfo {
address: string;
publicKey: string
}
export interface UseAuthProps {
balanceSetting?: BalanceSetting;
/** User will be prompted for authentication on start-up */
authenticateOnMount?: boolean;
userAccountInfo?: userAccountInfo | null
}
export const useAuth = ({ balanceSetting, authenticateOnMount = true }: UseAuthProps) => {
export const useAuth = ({ balanceSetting, authenticateOnMount = true, userAccountInfo = null }: UseAuthProps) => {
const address = useAuthStore((s) => s.address);
const publicKey = useAuthStore((s) => s.publicKey);
const name = useAuthStore((s) => s.name);
@ -45,12 +49,12 @@ const setBalance = useAuthStore((s) => s.setBalance);
const balanceSetIntervalRef = useRef<null | ReturnType<typeof setInterval>>(null);
const authenticateUser = useCallback(async () => {
const authenticateUser = useCallback(async (userAccountInfo?: userAccountInfo) => {
try {
setErrorLoadingUser(null);
setIsLoadingUser(true);
const account = await qortalRequest({
const account = userAccountInfo || await qortalRequest({
action: "GET_USER_ACCOUNT",
});
@ -104,7 +108,10 @@ const setBalance = useAuthStore((s) => s.setBalance);
if (authenticateOnMount) {
authenticateUser();
}
}, [authenticateOnMount, authenticateUser]);
if(userAccountInfo?.address && userAccountInfo?.publicKey){
authenticateUser(userAccountInfo);
}
}, [authenticateOnMount, authenticateUser, userAccountInfo?.address, userAccountInfo?.publicKey]);
useEffect(() => {
if (address && (balanceSetting?.onlyOnMount || (balanceSetting?.interval && !isNaN(balanceSetting?.interval)))) {