Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: session issues and minor fixes (converge branches) #501

Merged
merged 15 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/publication-detail-main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export default function PublicationDetailMain({
sx={{
width: 26,
height: 26,
border: (theme) => `solid 2px ${theme.palette.background.default}`,
border: (theme: any) => `solid 2px ${theme.palette.background.default}`,
}}
/>
<Typography variant="subtitle2" noWrap sx={{ ml: 1 }}>
Expand Down Expand Up @@ -338,7 +338,7 @@ export default function PublicationDetailMain({
pr: 1,
}}
>
{hasAccess ? (
{hasAccess && sessionData?.authenticated ? (
// @ts-ignore
<LeaveTipCard post={post} />
) : (
Expand Down
3 changes: 1 addition & 2 deletions src/components/subscribe-to-unlock-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface Props {
export const SubscribeToUnlockCard = ({
onSubscribe,
loadingSubscribe,
subscribeDisabled,
post,
}: Props) => {
const { terms } = useGetPolicyTerms(
Expand Down Expand Up @@ -58,7 +57,7 @@ export const SubscribeToUnlockCard = ({
sx={{ width: '100%', py: 1.5 }}
onClick={onSubscribe}
loading={loadingSubscribe}
disabled={subscribeDisabled}
// disabled={subscribeDisabled}
>
<IconPlayerPlay size={20} style={{ marginRight: 5 }} />
Join
Expand Down
41 changes: 27 additions & 14 deletions src/components/user-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,37 @@ interface UserNameAndBadgeProps {
address: Address;
}

export const UserNameAndBadge : FC<UserNameAndBadgeProps> = ({ name, address}) => {
export const UserNameAndBadge: FC<UserNameAndBadgeProps> = ({ name, address }) => {
return (
<Box sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-start',
}}>

<Typography sx={{mr:'2px'}}>{name}</Typography>
<Box sx={{
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
borderRadius: '50%',
}}>
justifyContent: 'flex-start',
}}
>
<Typography
sx={{
mr: '2px',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
maxWidth: '100px',
}}
>
{name}
</Typography>
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
borderRadius: '50%',
}}
>
<BadgeVerified address={address} />
</Box>
</Box>

);
}
};

4 changes: 2 additions & 2 deletions src/components/video-player/video-player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export const VideoPlayer: FC<VideoPlayerProps> = ({ src, titleMovie, onBack, sho
if (event.key === 'Escape' || event.key === 'Esc') onBack?.();
};

document.addEventListener('keydown', handleKeyDown);
document?.addEventListener('keydown', handleKeyDown);

return () => {
document.removeEventListener('keydown', handleKeyDown);
document?.removeEventListener('keydown', handleKeyDown);
};
}, [onBack]);

Expand Down
4 changes: 2 additions & 2 deletions src/hooks/use-account-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ export const useAccountSession = (): UseAccountSessionHook => {
// wait for web3auth ready state and allow bypass if
if ((isPending() || loading) && !data?.authenticated) return;
// is authenticated avoid re-run code below
if (sessionData?.authenticated) return;
if (sessionData?.authenticated || data?.type === 'ANONYMOUS') return;
// dispatch the session data and turn off the loading
dispatch(setSession({ session: data }))
dispatch(setAuthLoading({ isSessionLoading: false }));
}, [isSessionLoading]);
}, [isSessionLoading, data?.authenticated, data?.type]);

return {
logout: handleSessionExpired,
Expand Down
21 changes: 4 additions & 17 deletions src/hooks/use-web3-session.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useMemo } from 'react';
import { useWeb3Auth } from '@src/hooks/use-web3-auth';

/**
Expand All @@ -9,22 +8,10 @@ import { useWeb3Auth } from '@src/hooks/use-web3-auth';
*/
export function useWeb3Session() {
const { web3Auth } = useWeb3Auth();
const accountAbstractionProvider = web3Auth?.options?.accountAbstractionProvider;

const bundlerClient = useMemo(() => {
// @ts-ignore
return accountAbstractionProvider?.bundlerClient || null;
}, [accountAbstractionProvider]);

const smartAccount = useMemo(() => {
// @ts-ignore
return accountAbstractionProvider?.smartAccount || null;
}, [accountAbstractionProvider]);

const provider = useMemo(() => {
// @ts-ignore
return accountAbstractionProvider?.provider || null;
}, [accountAbstractionProvider]);
const accountAbstractionProvider: any = web3Auth?.options?.accountAbstractionProvider;
const bundlerClient = accountAbstractionProvider?.bundlerClient;
const smartAccount = accountAbstractionProvider?.smartAccount;
const provider = accountAbstractionProvider?.provider;

return {
bundlerClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ function FinanceQuickTransferModal({
try {
await transfer({ amount, recipient: address ?? '' });

onFinish();

const senderId = sessionData?.profile?.id ?? address;

// Build the notification payload
Expand Down Expand Up @@ -136,7 +138,6 @@ function FinanceQuickTransferModal({
notifySuccess(SUCCESS.TRANSFER_CREATED_SUCCESSFULLY, {
destination: isSame ? contactInfo?.metadata?.displayName : truncateAddress(address ?? ''),
});
onFinish();
} catch (err: any) {
notifyError(ERRORS.TRANSFER_FAILED_ERROR);
}
Expand Down
4 changes: 2 additions & 2 deletions src/sections/publication/view/publication-details-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export default function PublicationDetailsView({ id }: Props) {
justifyContent: 'center',
}}
>
{hasAccess ? (
{hasAccess && sessionData?.authenticated ? (
<MoviePlayView publication={data} loading={loading} />
) : (
<Box
Expand Down Expand Up @@ -236,7 +236,7 @@ export default function PublicationDetailsView({ id }: Props) {
zIndex: 2,
}}
onClick={handleSubscribe}
disabled={accessLoading || hasAccess || accessFetchingLoading}
// disabled={accessLoading || hasAccess || accessFetchingLoading}
loading={accessLoading || accessFetchingLoading}
>
<IconPlayerPlay fontSize="large" size={18} />
Expand Down
Loading
Loading