import { useSelector } from "react-redux" ; import { createSelector } from "reselect" ; import * as Etebase from "etebase" ; import * as store from "./store" ; import { usePromiseMemo } from "./helpers" ; export const credentialsSelector = createSelector ( ( state ) => state . credentials . storedSession , ( storedSession ) => { if ( storedSession ) { return Etebase . Account . restore ( storedSession ) ; } else { return Promise . resolve ( null ) ; } } ) ; export function useCredentials ( ) { const credentialsPromise = useSelector ( credentialsSelector ) ; return usePromiseMemo ( credentialsPromise , [ credentialsPromise ] ) ; }