Skip to content

Commit 01258f9

Browse files
authored
Merge pull request #733 from WatchItDev/app/fix/redux
fix: header skeleton
2 parents d37ea64 + c6503ab commit 01258f9

File tree

7 files changed

+29
-22
lines changed

7 files changed

+29
-22
lines changed

src/components/carousel/variants/carousel-top-titles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default function CarouselTopTitles({ posts, category }: Readonly<Carousel
4545
>
4646
<Carousel ref={carousel.carouselRef} {...carousel.carouselSettings}>
4747
{posts.map((post: Post) => (
48-
<Box key={`${category}-${post.id}`} sx={{ px: 0.75, height: '100%' }}>
48+
<Box key={`${category}-${post.id}`} sx={{ height: '100%' }}>
4949
<PosterTopTitles post={post} />
5050
</Box>
5151
))}

src/hooks/use-account-session.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const useAccountSession = (): UseAccountSessionHook => {
4848
const [loginInProgress, setLoginInProgress] = useState(false);
4949
const [verifyingUser, setVerifyingUser] = useState(false);
5050
const [userChecked, setUserChecked] = useState(false);
51-
const [initializing, setInitializing] = useState(!restoreDone);
51+
const [initializing, setInitializing] = useState(true);
5252

5353
const sessionRef = useRef(session);
5454
const lastVerifiedRef = useRef<Address | null>(null);
@@ -158,23 +158,40 @@ export const useAccountSession = (): UseAccountSessionHook => {
158158
}
159159
} catch {
160160
await logout();
161-
} finally {
162-
setUserChecked(true);
163-
setInitializing(false);
164161
}
165162
})();
166163
}, [logout]);
167164

165+
const handleConnected = async () => {
166+
try {
167+
await syncAddress();
168+
} finally {
169+
handleReady();
170+
}
171+
};
172+
173+
const handleReady = () => {
174+
setUserChecked(true);
175+
setInitializing(false);
176+
};
177+
178+
const verifyStatus = () => {
179+
if (web3Auth.status === 'connected' || web3Auth.status === 'ready') handleReady();
180+
};
181+
168182
useEffect(() => {
169183
if (!web3Auth || listenerAttached) return;
170184
listenerAttached = true;
185+
verifyStatus();
171186

172187
web3Auth.on(ADAPTER_EVENTS.DISCONNECTED, logout);
173-
web3Auth.on(ADAPTER_EVENTS.CONNECTED, syncAddress);
188+
web3Auth.on(ADAPTER_EVENTS.CONNECTED, handleConnected);
189+
web3Auth.on(ADAPTER_EVENTS.READY, handleReady);
174190

175191
return () => {
176192
web3Auth.off(ADAPTER_EVENTS.DISCONNECTED, logout);
177-
web3Auth.off(ADAPTER_EVENTS.CONNECTED, syncAddress);
193+
web3Auth.off(ADAPTER_EVENTS.CONNECTED, handleConnected);
194+
web3Auth.off(ADAPTER_EVENTS.READY, handleReady);
178195
listenerAttached = false;
179196
};
180197
}, [web3Auth, logout]);

src/layouts/_common/account-popover/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ export function AccountPopover() {
2828
const router = useRouter();
2929
const popover = usePopover();
3030
const { isLoginModalOpen, isAuthLoading } = useAuth();
31-
const { initializing } = useAccountSession();
31+
const { initializing, loading: sessionLoading } = useAccountSession();
3232

3333
if (isAuthLoading) {
3434
return <CircularProgress size={24} sx={{ color: '#fff' }} />;
3535
}
3636

37-
if (initializing) {
37+
if (initializing || sessionLoading) {
3838
return (
3939
<Skeleton
4040
variant="rounded"

src/pages/ownership.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ export default function FileManagerPage() {
2828
) : (
2929
<BlankView>
3030
<ComingSoonView
31-
deadline={'03/30/2025 21:30'}
32-
showDeadline={true}
3331
content={
3432
"The Ownership is evolving! Soon, you'll gManage digital rights, track licensing, and unlock the power of decentralized ownership. Stay tuned!"
3533
}

src/pages/studio.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ export default function OverviewFilePage() {
1414
>
1515
<BlankView>
1616
<ComingSoonView
17-
deadline={'03/30/2025 21:30'}
18-
showDeadline={true}
1917
content={
2018
"The Studio is evolving! Soon, you'll generate new content and enhance your creations with AI-driven tools for metadata, images, subtitles, voiceovers, and security checks. Stay tuned!"
2119
}

src/sections/explore/components/explore-top-publications.skeleton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const ExploreTopPublicationsSkeleton: React.FC = () => {
99
variant="rectangular"
1010
width={'100%'}
1111
height={'100%'}
12-
sx={{ mb: 1, mx: 0.5, mt: 2, borderRadius: 1 }}
12+
sx={{ mb: 1 }}
1313
/>
1414
<Box
1515
sx={{

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ export default function PublicationDetailsView({ id }: Readonly<PublicationDetai
5252
const { campaign, loading: campaignLoading, fetchSubscriptionCampaign } = useGetSubscriptionCampaign();
5353
const { isActive: isCampaignActive, loading: isActiveLoading, fetchIsActive } = useGetCampaignIsActive();
5454
const [loadPublications, { data: profilePublications, loading: profilePublicationsLoading }] = useGetPostsByAuthorLazyQuery();
55-
const [initialized, setInitialized] = useState(false);
5655

5756
const isAccessFullyChecked = !accessLoading && !isAuthorizedLoading && !isActiveLoading && !campaignLoading;
5857
const allLoaded = !publicationLoading && !isAuthLoading && !profilePublicationsLoading && isAccessFullyChecked;
5958
const isSponsoredButtonVisible = isCampaignActive && isAuthorized && isAccessFullyChecked;
6059
const isJoinButtonVisible = isAuthorized && !isCampaignActive && isAccessFullyChecked && !isSponsoredButtonVisible;
6160
const isPlayerVisible = hasAccess && session.authenticated && !accessLoading && !isAuthLoading;
62-
const loading = !initialized || (initialized && !publication);
61+
const accessChecked = hasAccess !== undefined;
62+
const loading = (!(allLoaded && accessChecked) && !isAuthLoading) || !publication;
6363

6464
useEffect(() => {
6565
if (!ownerAddress || publicationLoading || profilePublications?.getPostsByAuthor) return;
@@ -77,12 +77,6 @@ export default function PublicationDetailsView({ id }: Readonly<PublicationDetai
7777
loadPublication({variables: { getPostId: id }});
7878
}, [id, publication]);
7979

80-
useEffect(() => {
81-
if (allLoaded && !initialized) {
82-
setInitialized(true);
83-
}
84-
}, [allLoaded, initialized]);
85-
8680
const handleSubscribe = () => {
8781
if (!session.authenticated) {
8882
dispatch(openLoginModal());

0 commit comments

Comments
 (0)