Skip to content
Merged
Changes from 1 commit
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
19 changes: 14 additions & 5 deletions src/app/banners/BannerWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { RootState } from '../store';
import { PlanState } from '../store/slices/plan';
import { useSelector } from 'react-redux';

import { UserSettings } from '@internxt/sdk/dist/shared/types/userSettings';
import { BannerManager } from './BannerManager';
import { useEffect, useMemo, useState } from 'react';
import { userSelectors } from 'app/store/slices/user';
import FeaturesBanner from './FeaturesBanner';
import newStorageService from 'app/drive/services/new-storage.service';

const OFFER_END_DAY = new Date('2026-01-26');
const TIMEOUT = 90000;
Expand All @@ -15,17 +15,26 @@ const BannerWrapper = (): JSX.Element => {
const user = useSelector((state: RootState) => state.user.user) as UserSettings;
const plan = useSelector<RootState, PlanState>((state) => state.plan);
const isNewAccount = useSelector((state: RootState) => userSelectors.hasSignedToday(state));

const bannerManager = useMemo(() => new BannerManager(user, plan, OFFER_END_DAY), [user, plan, isNewAccount]);

const [bannersToShow, setBannersToShow] = useState({ showFreeBanner: false, showSubscriptionBanner: false });
const [showDelayedBanner, setShowDelayedBanner] = useState(false);
const [hasUploadedFirstFile, setHasUploadedFirstFile] = useState(false);

useEffect(() => {
const timeout = setTimeout(() => setShowDelayedBanner(true), TIMEOUT);
return () => clearTimeout(timeout);
newStorageService.hasUploadedFiles().then(({ hasUploadedFiles }) => {
if (hasUploadedFiles) {
setHasUploadedFirstFile(true);
}
});
}, []);
Comment on lines 23 to 29
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this logic only checks the upload status when mount hte banner, are this the behaviour that you want?
Add the related tests :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the intended behavior. I've used the same approach we have for the tutorial. I've tested it and confirmed that the banner doesn't appear after 90 seconds just from being on the homepage, and that it correctly appears 90 seconds after the first file upload. Adding the tests now.


useEffect(() => {
if (hasUploadedFirstFile) {
const timeout = setTimeout(() => setShowDelayedBanner(true), TIMEOUT);
return () => clearTimeout(timeout);
}
}, [hasUploadedFirstFile]);

useEffect(() => {
const newBanners = bannerManager.getBannersToShow();
setBannersToShow(() => ({
Expand Down
Loading