Skip to content
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.

Commit

Permalink
Remove legacy maybe usages
Browse files Browse the repository at this point in the history
  • Loading branch information
orzechdev committed Sep 7, 2020
1 parent 0ad7c51 commit 3d86ca2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
10 changes: 3 additions & 7 deletions src/views/Category/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
convertSortByFromString,
convertToAttributeScalar,
getGraphqlIdFromDBId,
maybe,
} from "../../core/utils";
import Page from "./Page";
import {
Expand Down Expand Up @@ -155,12 +154,9 @@ export const View: React.FC<ViewProps> = ({ match }) => {
return <OfflinePlaceholder />;
}

const canDisplayFilters = maybe(
() =>
!!categoryData.data.attributes.edges &&
!!categoryData.data.category.name,
false
);
const canDisplayFilters =
!!categoryData.data?.attributes?.edges &&
!!categoryData.data?.category?.name;

return (
<TypedCategoryProductsQuery variables={variables}>
Expand Down
9 changes: 3 additions & 6 deletions src/views/Collection/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,9 @@ export const View: React.FC<ViewProps> = ({ match }) => {
return <OfflinePlaceholder />;
}

const canDisplayFilters = maybe(
() =>
!!collectionData.data.attributes.edges &&
!!collectionData.data.collection.name,
false
);
const canDisplayFilters =
!!collectionData.data?.attributes?.edges &&
!!collectionData.data?.collection?.name;

return (
<TypedCollectionProductsQuery variables={variables}>
Expand Down
6 changes: 2 additions & 4 deletions src/views/Search/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,8 @@ export const View: React.FC<ViewProps> = ({ match }) => {
loaderFull
>
{({ loading, data, loadMore }) => {
const canDisplayFilters = maybe(
() => !!data.attributes.edges && !!data.products.edges,
false
);
const canDisplayFilters =
!!data?.attributes?.edges && !!data?.products?.edges;

if (canDisplayFilters) {
const handleLoadMore = () =>
Expand Down

0 comments on commit 3d86ca2

Please sign in to comment.