Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
fix: Prevent infinite loading if ENABLE_B2C_SUBSCRIPTIONS config not …
Browse files Browse the repository at this point in the history
…set up
  • Loading branch information
julianajlk committed Dec 15, 2023
1 parent c3b4aca commit fbceaa6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/order-history/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ export const storeName = 'orderHistory';
export const pageSelector = state => ({
...state[storeName],
});

export const loadingOrderHistorySelector = (state) => (
state[storeName].loading
);
11 changes: 10 additions & 1 deletion src/orders-and-subscriptions/OrdersAndSubscriptionsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ import {
loadingSelector,
showSubscriptionSelector,
} from './selectors';
import { loadingOrderHistorySelector } from '../order-history/selectors';
import messages from './OrdersAndSubscriptionsPage.messages';

const OrdersAndSubscriptionsPage = () => {
const { formatMessage } = useIntl();
const dispatch = useDispatch();
const isLoading = useSelector(loadingSelector);
const isLoadingOrderHistoryOnly = useSelector(loadingOrderHistorySelector);
const hasError = useSelector(errorSelector);
const { subscriptions } = useSelector(subscriptionsSelector);

Expand Down Expand Up @@ -87,9 +89,16 @@ const OrdersAndSubscriptionsPage = () => {
</div>
);

if (isLoading) {
// Now that loading initial state is true, if subscriptions is not enabled,
// it will never fetch subscriptions, want to prevent from local infinite loading
if (isSubscriptionDisabled) {
if (isLoadingOrderHistoryOnly) {
return renderLoading();
}
} else if (isLoading) {
return renderLoading();
}

if (shouldShowOrderHistoryOnly) {
return renderOrderHistoryOnly();
}
Expand Down

0 comments on commit fbceaa6

Please sign in to comment.