File tree 3 files changed +12
-4
lines changed
packages/gatsby-theme/src/components
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';
3
3
import { loginUser } from '../../utils/auth' ;
4
4
import { BookmarkButton } from '../shared/buttons' ;
5
5
import { BookmarkTutorial } from '../../utils/queries' ;
6
+ import { optionalChaining } from '../../utils/helpers' ;
7
+
6
8
import { handleMutationResponse , ApiErrors } from '../../utils/errorHandling' ;
7
9
8
10
const BookmarkMutation = ( { tutorial } ) => (
@@ -13,7 +15,9 @@ const BookmarkMutation = ({ tutorial }) => (
13
15
} }
14
16
>
15
17
{ bookmark => {
16
- let bookmarked = tutorial . viewerUserTutorial . bookmarked ;
18
+ let bookmarked = optionalChaining (
19
+ ( ) => tutorial . viewerUserTutorial . bookmarked ,
20
+ ) ;
17
21
return (
18
22
< BookmarkButton
19
23
active = { bookmarked }
Original file line number Diff line number Diff line change @@ -4,13 +4,14 @@ import { loginUser } from '../../utils/auth';
4
4
import { handleMutationResponse , ApiErrors } from '../../utils/errorHandling' ;
5
5
import { VoteButton } from '../shared/buttons' ;
6
6
import { Heading , Flex } from '../shared/base' ;
7
+ import { optionalChaining } from '../../utils/helpers' ;
7
8
import { UpvoteTutorial } from '../../utils/queries' ;
8
9
9
10
const UpvoteMutation = ( { tutorial } ) => (
10
11
< Mutation mutation = { UpvoteTutorial } variables = { { id : tutorial . id } } >
11
12
{ 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 ) ;
14
15
return (
15
16
< Flex
16
17
flexDirection = "column"
Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
+ import { optionalChaining } from '../../utils/helpers' ;
2
3
import { Text } from './base' ;
3
4
4
5
const Percentage = ( { tutorial } ) => {
5
- let progress = tutorial . viewerUserTutorial . currentChapter ;
6
+ let progress = optionalChaining (
7
+ ( ) => tutorial . viewerUserTutorial . currentChapter ,
8
+ ) ;
6
9
let percentage = progress
7
10
? Math . floor ( ( progress / tutorial . numberofChapters ) * 100 )
8
11
: 0 ;
You can’t perform that action at this time.
0 commit comments