Skip to content

Commit

Permalink
add isAuthenticating property
Browse files Browse the repository at this point in the history
  • Loading branch information
milukove committed Aug 4, 2023
1 parent b6b97e6 commit b83b6df
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 5 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.1] 2022-08-04

### Added

- `isAuthenticating` boolean property, to detect when user authentication state has been checked
2 changes: 2 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export declare type GrinderyLoginContextProps = {
user: string | null;
/** User address */
address: string | null;
/** User authentication loading state */
isAuthenticating: boolean;
/** Connect user */
connect: () => void;
/** Disconnect user */
Expand Down
7 changes: 7 additions & 0 deletions dist/use-grindery-login.cjs.development.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/use-grindery-login.cjs.development.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/use-grindery-login.cjs.production.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/use-grindery-login.cjs.production.min.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions dist/use-grindery-login.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/use-grindery-login.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "use-grindery-login",
"author": "milukove",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
10 changes: 10 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export type GrinderyLoginContextProps = {
/** User address */
address: string | null;

/** User authentication loading state */
isAuthenticating: boolean;

/** Connect user */
connect: () => void;

Expand All @@ -53,6 +56,7 @@ const defaultContext = {
token: null,
address: null,
user: null,
isAuthenticating: true,
connect: () => {},
disconnect: () => {},
};
Expand Down Expand Up @@ -83,6 +87,9 @@ export const GrinderyLoginProvider = ({
// User address
const [address, setAddress] = useState<string | null>(null);

// User authentication loading state
const [isAuthenticating, setIsAuthenticating] = useState<boolean>(true);

// Connect user
const connect = async () => {
const currentUrl = window.location.href.split('?')[0];
Expand Down Expand Up @@ -151,6 +158,8 @@ export const GrinderyLoginProvider = ({
setToken(event.data?.params?.token || null);
setAddress(event.data?.params?.address || null);
setUser(event.data?.params?.user || null);

setIsAuthenticating(false);
}
}

Expand All @@ -171,6 +180,7 @@ export const GrinderyLoginProvider = ({
token,
user,
address,
isAuthenticating,
connect,
disconnect,
}}
Expand Down

0 comments on commit b83b6df

Please sign in to comment.