Skip to content

Commit 44b11e2

Browse files
authored
Merge pull request #486 from WatchItDev/fix/web3auth/session
fix: bundler client null and session data anonymous
2 parents 139ee9a + f02fbe9 commit 44b11e2

File tree

6 files changed

+13
-27
lines changed

6 files changed

+13
-27
lines changed

src/components/publication-detail-main.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export default function PublicationDetailMain({
224224
sx={{
225225
width: 26,
226226
height: 26,
227-
border: (theme) => `solid 2px ${theme.palette.background.default}`,
227+
border: (theme: any) => `solid 2px ${theme.palette.background.default}`,
228228
}}
229229
/>
230230
<Typography variant="subtitle2" noWrap sx={{ ml: 1 }}>
@@ -338,7 +338,7 @@ export default function PublicationDetailMain({
338338
pr: 1,
339339
}}
340340
>
341-
{hasAccess ? (
341+
{hasAccess && sessionData?.authenticated ? (
342342
// @ts-ignore
343343
<LeaveTipCard post={post} />
344344
) : (

src/components/subscribe-to-unlock-card.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ interface Props {
1616
export const SubscribeToUnlockCard = ({
1717
onSubscribe,
1818
loadingSubscribe,
19-
subscribeDisabled,
2019
post,
2120
}: Props) => {
2221
const { terms } = useGetPolicyTerms(
@@ -58,7 +57,7 @@ export const SubscribeToUnlockCard = ({
5857
sx={{ width: '100%', py: 1.5 }}
5958
onClick={onSubscribe}
6059
loading={loadingSubscribe}
61-
disabled={subscribeDisabled}
60+
// disabled={subscribeDisabled}
6261
>
6362
<IconPlayerPlay size={20} style={{ marginRight: 5 }} />
6463
Join

src/components/video-player/video-player.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ export const VideoPlayer: FC<VideoPlayerProps> = ({ src, titleMovie, onBack, sho
3535
if (event.key === 'Escape' || event.key === 'Esc') onBack?.();
3636
};
3737

38-
document.addEventListener('keydown', handleKeyDown);
38+
document?.addEventListener('keydown', handleKeyDown);
3939

4040
return () => {
41-
document.removeEventListener('keydown', handleKeyDown);
41+
document?.removeEventListener('keydown', handleKeyDown);
4242
};
4343
}, [onBack]);
4444

src/hooks/use-account-session.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ export const useAccountSession = (): UseAccountSessionHook => {
6565
// wait for web3auth ready state and allow bypass if
6666
if ((isPending() || loading) && !data?.authenticated) return;
6767
// is authenticated avoid re-run code below
68-
if (sessionData?.authenticated) return;
68+
if (sessionData?.authenticated || data?.type === 'ANONYMOUS') return;
6969
// dispatch the session data and turn off the loading
7070
dispatch(setSession({ session: data }))
7171
dispatch(setAuthLoading({ isSessionLoading: false }));
72-
}, [isSessionLoading]);
72+
}, [isSessionLoading, data]);
7373

7474
return {
7575
logout: handleSessionExpired,

src/hooks/use-web3-session.ts

+4-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useMemo } from 'react';
21
import { useWeb3Auth } from '@src/hooks/use-web3-auth';
32

43
/**
@@ -9,22 +8,10 @@ import { useWeb3Auth } from '@src/hooks/use-web3-auth';
98
*/
109
export function useWeb3Session() {
1110
const { web3Auth } = useWeb3Auth();
12-
const accountAbstractionProvider = web3Auth?.options?.accountAbstractionProvider;
13-
14-
const bundlerClient = useMemo(() => {
15-
// @ts-ignore
16-
return accountAbstractionProvider?.bundlerClient || null;
17-
}, [accountAbstractionProvider]);
18-
19-
const smartAccount = useMemo(() => {
20-
// @ts-ignore
21-
return accountAbstractionProvider?.smartAccount || null;
22-
}, [accountAbstractionProvider]);
23-
24-
const provider = useMemo(() => {
25-
// @ts-ignore
26-
return accountAbstractionProvider?.provider || null;
27-
}, [accountAbstractionProvider]);
11+
const accountAbstractionProvider: any = web3Auth?.options?.accountAbstractionProvider;
12+
const bundlerClient = accountAbstractionProvider?.bundlerClient;
13+
const smartAccount = accountAbstractionProvider?.smartAccount;
14+
const provider = accountAbstractionProvider?.provider;
2815

2916
return {
3017
bundlerClient,

src/sections/publication/view/publication-details-view.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export default function PublicationDetailsView({ id }: Props) {
169169
justifyContent: 'center',
170170
}}
171171
>
172-
{hasAccess ? (
172+
{hasAccess && sessionData?.authenticated ? (
173173
<MoviePlayView publication={data} loading={loading} />
174174
) : (
175175
<Box
@@ -236,7 +236,7 @@ export default function PublicationDetailsView({ id }: Props) {
236236
zIndex: 2,
237237
}}
238238
onClick={handleSubscribe}
239-
disabled={accessLoading || hasAccess || accessFetchingLoading}
239+
// disabled={accessLoading || hasAccess || accessFetchingLoading}
240240
loading={accessLoading || accessFetchingLoading}
241241
>
242242
<IconPlayerPlay fontSize="large" size={18} />

0 commit comments

Comments
 (0)