Skip to content

Commit 46da50b

Browse files
authored
Merge pull request #501 from WatchItDev/main
refactor: session issues and minor fixes (converge branches)
2 parents e976732 + 0baddc8 commit 46da50b

23 files changed

+982
-795
lines changed

src/components/publication-detail-main.tsx

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 2 deletions
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/user-item/index.tsx

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,24 +151,37 @@ interface UserNameAndBadgeProps {
151151
address: Address;
152152
}
153153

154-
export const UserNameAndBadge : FC<UserNameAndBadgeProps> = ({ name, address}) => {
154+
export const UserNameAndBadge: FC<UserNameAndBadgeProps> = ({ name, address }) => {
155155
return (
156-
<Box sx={{
157-
display: 'flex',
158-
alignItems: 'center',
159-
justifyContent: 'flex-start',
160-
}}>
161-
162-
<Typography sx={{mr:'2px'}}>{name}</Typography>
163-
<Box sx={{
156+
<Box
157+
sx={{
164158
display: 'flex',
165159
alignItems: 'center',
166-
justifyContent: 'center',
167-
borderRadius: '50%',
168-
}}>
160+
justifyContent: 'flex-start',
161+
}}
162+
>
163+
<Typography
164+
sx={{
165+
mr: '2px',
166+
whiteSpace: 'nowrap',
167+
overflow: 'hidden',
168+
textOverflow: 'ellipsis',
169+
maxWidth: '100px',
170+
}}
171+
>
172+
{name}
173+
</Typography>
174+
<Box
175+
sx={{
176+
display: 'flex',
177+
alignItems: 'center',
178+
justifyContent: 'center',
179+
borderRadius: '50%',
180+
}}
181+
>
169182
<BadgeVerified address={address} />
170183
</Box>
171184
</Box>
172-
173185
);
174-
}
186+
};
187+

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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?.authenticated, data?.type]);
7373

7474
return {
7575
logout: handleSessionExpired,

src/hooks/use-web3-session.ts

Lines changed: 4 additions & 17 deletions
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/finance/components/finance-quick-transfer-modal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ function FinanceQuickTransferModal({
102102
try {
103103
await transfer({ amount, recipient: address ?? '' });
104104

105+
onFinish();
106+
105107
const senderId = sessionData?.profile?.id ?? address;
106108

107109
// Build the notification payload
@@ -136,7 +138,6 @@ function FinanceQuickTransferModal({
136138
notifySuccess(SUCCESS.TRANSFER_CREATED_SUCCESSFULLY, {
137139
destination: isSame ? contactInfo?.metadata?.displayName : truncateAddress(address ?? ''),
138140
});
139-
onFinish();
140141
} catch (err: any) {
141142
notifyError(ERRORS.TRANSFER_FAILED_ERROR);
142143
}

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

Lines changed: 2 additions & 2 deletions
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)