Extract useGoogleAuth from app.tsx

This commit is contained in:
Przemek Więch
2026-06-11 17:31:52 +02:00
parent 843e0f528c
commit ef2653b51f
3 changed files with 23 additions and 5 deletions

View File

@@ -0,0 +1,19 @@
import {useState} from 'react';
import {googleDriveService} from '../datasource/google_drive_service';
/**
* Custom React hook to manage and track the state of Google Drive OAuth2 credentials.
*/
export function useGoogleAuth() {
/** Tracks whether the user has a valid cached Google Drive OAuth access token. */
const [hasGoogleToken, setHasGoogleToken] = useState(
() => !!googleDriveService.getAccessToken(),
);
return {
/** Tracks whether the user has a valid cached Google Drive OAuth access token. */
hasGoogleToken,
/** Function to update the token presence state in React. */
setHasGoogleToken,
};
}