@@ -10,40 +10,38 @@ import withAppProps, { AppProps } from "dataflow/withAppProps";
1010import useUser from "components/context/UserContext" ;
1111import useLogin from "auth/useLogin" ;
1212import useLibraryContext from "components/context/LibraryContext" ;
13- import useCredentials from "auth/useCredentials" ;
1413import {
1514 getMagazineReaderUrl ,
1615 getMagazineAllowedOrigin ,
1716 MAGAZINE_CONFIG
1817} from "config/magazines" ;
1918import Head from "next/head" ;
2019import BreadcrumbBar from "components/BreadcrumbBar" ;
21- import { EkirjastoAuthType } from "types/opds1" ;
2220import { EKIRJASTO_AUTH_TYPE } from "utils/constants" ;
2321
2422const MagazinesFixedContent : React . FC = ( ) => {
2523 const iframeRef = React . useRef < HTMLIFrameElement | null > ( null ) ;
26- const { token, signIn , getEkirjastoToken } = useUser ( ) ;
24+ const { token, getEkirjastoToken } = useUser ( ) ;
2725 const { initLogin } = useLogin ( ) ;
2826 const { slug, authMethods } = useLibraryContext ( ) ;
29- const { credentials, setCredentials, clearCredentials } = useCredentials (
30- slug ,
31- authMethods
32- ) ;
33- const ekirMethod = authMethods . find ( method => method . type === EKIRJASTO_AUTH_TYPE )
34- let ekirjastoToken : string | undefined
27+ const ekirMethod = authMethods . find (
28+ method => method . type === EKIRJASTO_AUTH_TYPE
29+ ) ;
30+ let ekirjastoToken : string | undefined ;
3531 if ( ekirMethod && token ) {
3632 try {
37- //Get the ekirjastoToken
38- const ekirjastoTokenUrl = ekirMethod . links . find ( link => link . rel === "ekirjasto_token" ) ?. href
39- ekirjastoToken = getEkirjastoToken ( token , ekirjastoTokenUrl )
33+ //Get the ekirjastoToken
34+ const ekirjastoTokenUrl = ekirMethod . links . find (
35+ link => link . rel === "ekirjasto_token"
36+ ) ?. href ;
37+ ekirjastoToken = getEkirjastoToken ( token , ekirjastoTokenUrl ) ;
4038 } catch ( error ) {
4139 //Can not start the reader so should show not logged in or something
4240 }
4341 }
4442 if ( ! token ) {
45- console . log ( "There is no token so should be logged out" )
46- ekirjastoToken = undefined
43+ console . log ( "There is no token so should be logged out" ) ;
44+ ekirjastoToken = undefined ;
4745 }
4846
4947 const storageKey = React . useMemo (
@@ -69,10 +67,9 @@ const MagazinesFixedContent: React.FC = () => {
6967 const allowedOrigin = getMagazineAllowedOrigin ( ) ;
7068
7169 if ( ! token ) {
72- console . log ( "No token!" )
73-
70+ console . log ( "No token!" ) ;
7471 }
75-
72+
7673 if ( e . origin !== allowedOrigin || typeof e . data !== "string" ) return ;
7774
7875 if ( e . data === "ewl:unauthorized" ) {
@@ -100,7 +97,7 @@ const MagazinesFixedContent: React.FC = () => {
10097 } ) ;
10198 }
10299 } ,
103- [ initLogin , ekirjastoToken , storageKey ]
100+ [ initLogin , ekirjastoToken , token , storageKey ]
104101 ) ;
105102
106103 React . useEffect ( ( ) => {
0 commit comments