Skip to content

Commit 9b30bdb

Browse files
authored
Merge pull request #393 from oasisprotocol/ml/fix-istokenexpired-only-updated-in-a-10-second-interval
Fix isTokenExpired only updated in a 10-second interval
2 parents a73448a + f13de24 commit 9b30bdb

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

.changelog/393.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix isTokenExpired only updated in a 10-second interval

src/contexts/RoflAppBackendAuth/Provider.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ export function RoflAppBackendAuthProvider({ children }: { children: ReactNode }
3939
}
4040
}, [isInitialLoad, isConnected, token])
4141

42+
useEffect(() => {
43+
const currentToken = window.localStorage.getItem('jwt')
44+
if (currentToken && address) {
45+
const expired = isJWTExpired(currentToken, address)
46+
setIsTokenExpired(expired)
47+
}
48+
}, [address, token])
49+
4250
useInterval(() => {
4351
const currentToken = window.localStorage.getItem('jwt')
4452
if (currentToken && address) {

0 commit comments

Comments
 (0)