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

Fix views crashing when description or content fields are null #997

Merged
merged 2 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/views/Article/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { TypedArticleQuery } from "./query";

import "./scss/index.scss";

const canDisplay = page =>
maybe(() => !!page && !!page.title && !!page.content);
const canDisplay = page => maybe(() => !!page && !!page.title);
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe? 👮

Suggested change
const canDisplay = page => maybe(() => !!page && !!page.title);
const canDisplay = page => !!page?.title;


const getHeaderImage = (collection: Article_collection) =>
maybe(() => collection.backgroundImage.url);

Expand Down
12 changes: 5 additions & 7 deletions src/views/Product/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,8 @@ import { IProps } from "./types";
import "./scss/index.scss";

const canDisplay = (product: ProductDetails_product) =>
maybe(
() =>
!!product.description &&
!!product.name &&
!!product.# &&
!!product.variants
);
maybe(() => !!product.name && !!product.# && !!product.variants);
Copy link
Contributor

Choose a reason for hiding this comment

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

👮

Copy link
Contributor

Choose a reason for hiding this comment

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

☝️

Copy link
Member

Choose a reason for hiding this comment

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

👀

Copy link
Author

Choose a reason for hiding this comment

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


const extractMeta = (product: ProductDetails_product, url: string) => ({
custom: [
{
Expand Down Expand Up @@ -127,6 +122,7 @@ const View: NextPage<ViewProps> = ({ query: { id } }) => {
<NetworkStatus>
{isOnline => {
const { product } = data;

if (canDisplay(product)) {
return (
<MetaWrapper
Expand All @@ -152,6 +148,8 @@ const View: NextPage<ViewProps> = ({ query: { id } }) => {
if (!isOnline) {
return <OfflinePlaceholder />;
}

return <NotFound />;
}}
</NetworkStatus>
)}
Expand Down