remove subsciption and plan state and directly read and write localstorage value
This commit is contained in:
parent
a886488865
commit
489a83762a
|
@ -25,8 +25,9 @@ import {
|
||||||
import constants from 'utils/strings/constants';
|
import constants from 'utils/strings/constants';
|
||||||
import AlertBanner from './components/AlertBanner';
|
import AlertBanner from './components/AlertBanner';
|
||||||
import { Alert, Button, Jumbotron } from 'react-bootstrap';
|
import { Alert, Button, Jumbotron } from 'react-bootstrap';
|
||||||
import subscriptionService, { Plan } from 'services/subscriptionService';
|
import subscriptionService from 'services/subscriptionService';
|
||||||
import PlanSelector from './components/PlanSelector';
|
import PlanSelector from './components/PlanSelector';
|
||||||
|
import { planIsActive } from 'utils/billingUtil';
|
||||||
|
|
||||||
const DATE_CONTAINER_HEIGHT = 45;
|
const DATE_CONTAINER_HEIGHT = 45;
|
||||||
const IMAGE_CONTAINER_HEIGHT = 200;
|
const IMAGE_CONTAINER_HEIGHT = 200;
|
||||||
|
@ -137,8 +138,6 @@ export default function Gallery(props: Props) {
|
||||||
const [bannerErrorCode, setBannerErrorCode] = useState<number>(null);
|
const [bannerErrorCode, setBannerErrorCode] = useState<number>(null);
|
||||||
const [sinceTime, setSinceTime] = useState(0);
|
const [sinceTime, setSinceTime] = useState(0);
|
||||||
const [isFirstLoad, setIsFirstLoad] = useState(false);
|
const [isFirstLoad, setIsFirstLoad] = useState(false);
|
||||||
const [plans, setPlans] = useState<Plan[]>(null);
|
|
||||||
|
|
||||||
const loadingBar = useRef(null);
|
const loadingBar = useRef(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const key = getKey(SESSION_KEYS.ENCRYPTION_KEY);
|
const key = getKey(SESSION_KEYS.ENCRYPTION_KEY);
|
||||||
|
@ -154,8 +153,6 @@ export default function Gallery(props: Props) {
|
||||||
collections,
|
collections,
|
||||||
data
|
data
|
||||||
);
|
);
|
||||||
const plans = await subscriptionService.getPlans();
|
|
||||||
await subscriptionService.getUserSubscription();
|
|
||||||
const collectionAndItsLatestFile = await getCollectionAndItsLatestFile(
|
const collectionAndItsLatestFile = await getCollectionAndItsLatestFile(
|
||||||
nonEmptyCollections,
|
nonEmptyCollections,
|
||||||
data
|
data
|
||||||
|
@ -163,10 +160,8 @@ export default function Gallery(props: Props) {
|
||||||
setData(data);
|
setData(data);
|
||||||
setCollections(nonEmptyCollections);
|
setCollections(nonEmptyCollections);
|
||||||
setCollectionAndItsLatestFile(collectionAndItsLatestFile);
|
setCollectionAndItsLatestFile(collectionAndItsLatestFile);
|
||||||
setPlans(plans);
|
|
||||||
const favItemIds = await getFavItemIds(data);
|
const favItemIds = await getFavItemIds(data);
|
||||||
setFavItemIds(favItemIds);
|
setFavItemIds(favItemIds);
|
||||||
|
|
||||||
await syncWithRemote();
|
await syncWithRemote();
|
||||||
setIsFirstLoad(false);
|
setIsFirstLoad(false);
|
||||||
};
|
};
|
||||||
|
@ -184,6 +179,9 @@ export default function Gallery(props: Props) {
|
||||||
data
|
data
|
||||||
);
|
);
|
||||||
const favItemIds = await getFavItemIds(data);
|
const favItemIds = await getFavItemIds(data);
|
||||||
|
await subscriptionService.updatePlans();
|
||||||
|
await subscriptionService.syncSubscription();
|
||||||
|
|
||||||
setCollections(nonEmptyCollections);
|
setCollections(nonEmptyCollections);
|
||||||
if (isUpdated) {
|
if (isUpdated) {
|
||||||
setData(data);
|
setData(data);
|
||||||
|
@ -355,7 +353,7 @@ export default function Gallery(props: Props) {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<AlertBanner bannerErrorCode={bannerErrorCode} />
|
<AlertBanner bannerErrorCode={bannerErrorCode} />
|
||||||
{!subscriptionService.hasActivePaidPlan() && (
|
{!planIsActive() && (
|
||||||
<Button
|
<Button
|
||||||
id="checkout"
|
id="checkout"
|
||||||
variant="primary"
|
variant="primary"
|
||||||
|
@ -367,7 +365,6 @@ export default function Gallery(props: Props) {
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<PlanSelector
|
<PlanSelector
|
||||||
plans={plans}
|
|
||||||
modalView={props.planModalView}
|
modalView={props.planModalView}
|
||||||
closeModal={() => props.setPlanModalView(false)}
|
closeModal={() => props.setPlanModalView(false)}
|
||||||
setBannerErrorCode={setBannerErrorCode}
|
setBannerErrorCode={setBannerErrorCode}
|
||||||
|
|
Loading…
Reference in a new issue