File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed
packages/gatsby-theme/src/components Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import { Mutation } from 'react-apollo';
33import { loginUser } from '../../utils/auth' ;
44import { BookmarkButton } from '../shared/buttons' ;
55import { BookmarkTutorial } from '../../utils/queries' ;
6+ import { optionalChaining } from '../../utils/helpers' ;
7+
68import { handleMutationResponse , ApiErrors } from '../../utils/errorHandling' ;
79
810const BookmarkMutation = ( { tutorial } ) => (
@@ -13,7 +15,9 @@ const BookmarkMutation = ({ tutorial }) => (
1315 } }
1416 >
1517 { bookmark => {
16- let bookmarked = tutorial . viewerUserTutorial . bookmarked ;
18+ let bookmarked = optionalChaining (
19+ ( ) => tutorial . viewerUserTutorial . bookmarked ,
20+ ) ;
1721 return (
1822 < BookmarkButton
1923 active = { bookmarked }
Original file line number Diff line number Diff line change @@ -4,13 +4,14 @@ import { loginUser } from '../../utils/auth';
44import { handleMutationResponse , ApiErrors } from '../../utils/errorHandling' ;
55import { VoteButton } from '../shared/buttons' ;
66import { Heading , Flex } from '../shared/base' ;
7+ import { optionalChaining } from '../../utils/helpers' ;
78import { UpvoteTutorial } from '../../utils/queries' ;
89
910const UpvoteMutation = ( { tutorial } ) => (
1011 < Mutation mutation = { UpvoteTutorial } variables = { { id : tutorial . id } } >
1112 { upvote => {
12- let active = tutorial . viewerUserTutorial . upvoted ;
13- let upvotes = tutorial . upvotes ;
13+ let active = optionalChaining ( ( ) => tutorial . viewerUserTutorial . upvoted ) ;
14+ let upvotes = optionalChaining ( ( ) => tutorial . upvotes ) ;
1415 return (
1516 < Flex
1617 flexDirection = "column"
Original file line number Diff line number Diff line change 11import * as React from 'react' ;
2+ import { optionalChaining } from '../../utils/helpers' ;
23import { Text } from './base' ;
34
45const Percentage = ( { tutorial } ) => {
5- let progress = tutorial . viewerUserTutorial . currentChapter ;
6+ let progress = optionalChaining (
7+ ( ) => tutorial . viewerUserTutorial . currentChapter ,
8+ ) ;
69 let percentage = progress
710 ? Math . floor ( ( progress / tutorial . numberofChapters ) * 100 )
811 : 0 ;
You can’t perform that action at this time.
0 commit comments