File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -55,16 +55,16 @@ class CreateLink extends Component {
55
55
mutation = { POST_MUTATION }
56
56
variables = { { description, url } }
57
57
onCompleted = { ( ) => this . props . history . push ( '/new/1' ) }
58
- update = { ( cache , { data : { post } } ) => {
58
+ update = { ( store , { data : { post } } ) => {
59
59
const first = LINKS_PER_PAGE
60
60
const skip = 0
61
61
const orderBy = 'createdAt_DESC'
62
- const data = cache . readQuery ( {
62
+ const data = store . readQuery ( {
63
63
query : FEED_QUERY ,
64
64
variables : { first, skip, orderBy }
65
65
} )
66
66
data . feed . links . unshift ( post )
67
- cache . writeQuery ( {
67
+ store . writeQuery ( {
68
68
query : FEED_QUERY ,
69
69
data,
70
70
variables : { first, skip, orderBy }
Original file line number Diff line number Diff line change @@ -35,8 +35,8 @@ class Link extends Component {
35
35
< Mutation
36
36
mutation = { VOTE_MUTATION }
37
37
variables = { { linkId : link . id } }
38
- update = { ( cache , { data : { vote } } ) =>
39
- updateStoreAfterVote ( cache , vote , link . id )
38
+ update = { ( store , { data : { vote } } ) =>
39
+ updateStoreAfterVote ( store , vote , link . id )
40
40
}
41
41
>
42
42
{ voteMutation => (
Original file line number Diff line number Diff line change @@ -81,21 +81,21 @@ const NEW_VOTES_SUBSCRIPTION = gql`
81
81
`
82
82
83
83
class LinkList extends Component {
84
- _updateCacheAfterVote = ( cache , createVote , linkId ) => {
84
+ _updateCacheAfterVote = ( store , createVote , linkId ) => {
85
85
const isNewPage = this . props . location . pathname . includes ( 'new' )
86
86
const page = parseInt ( this . props . match . params . page , 10 )
87
87
88
88
const skip = isNewPage ? ( page - 1 ) * LINKS_PER_PAGE : 0
89
89
const first = isNewPage ? LINKS_PER_PAGE : 100
90
90
const orderBy = isNewPage ? 'createdAt_DESC' : null
91
- const data = cache . readQuery ( {
91
+ const data = store . readQuery ( {
92
92
query : FEED_QUERY ,
93
93
variables : { first, skip, orderBy }
94
94
} )
95
95
96
96
const votedLink = data . feed . links . find ( link => link . id === linkId )
97
97
votedLink . votes = createVote . link . votes
98
- cache . writeQuery ( { query : FEED_QUERY , data } )
98
+ store . writeQuery ( { query : FEED_QUERY , data } )
99
99
}
100
100
101
101
_getQueryVariables = ( ) => {
You can’t perform that action at this time.
0 commit comments