Skip to content

Commit 0433ca0

Browse files
author
Carlos Rufo Jimenez
committed
fix(cache): replaced by store
1 parent 2046fed commit 0433ca0

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/components/CreateLink.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ class CreateLink extends Component {
5555
mutation={POST_MUTATION}
5656
variables={{ description, url }}
5757
onCompleted={() => this.props.history.push('/new/1')}
58-
update={(cache, { data: { post } }) => {
58+
update={(store, { data: { post } }) => {
5959
const first = LINKS_PER_PAGE
6060
const skip = 0
6161
const orderBy = 'createdAt_DESC'
62-
const data = cache.readQuery({
62+
const data = store.readQuery({
6363
query: FEED_QUERY,
6464
variables: { first, skip, orderBy }
6565
})
6666
data.feed.links.unshift(post)
67-
cache.writeQuery({
67+
store.writeQuery({
6868
query: FEED_QUERY,
6969
data,
7070
variables: { first, skip, orderBy }

src/components/Link.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class Link extends Component {
3535
<Mutation
3636
mutation={VOTE_MUTATION}
3737
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)
4040
}
4141
>
4242
{voteMutation => (

src/components/LinkList.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,21 @@ const NEW_VOTES_SUBSCRIPTION = gql`
8181
`
8282

8383
class LinkList extends Component {
84-
_updateCacheAfterVote = (cache, createVote, linkId) => {
84+
_updateCacheAfterVote = (store, createVote, linkId) => {
8585
const isNewPage = this.props.location.pathname.includes('new')
8686
const page = parseInt(this.props.match.params.page, 10)
8787

8888
const skip = isNewPage ? (page - 1) * LINKS_PER_PAGE : 0
8989
const first = isNewPage ? LINKS_PER_PAGE : 100
9090
const orderBy = isNewPage ? 'createdAt_DESC' : null
91-
const data = cache.readQuery({
91+
const data = store.readQuery({
9292
query: FEED_QUERY,
9393
variables: { first, skip, orderBy }
9494
})
9595

9696
const votedLink = data.feed.links.find(link => link.id === linkId)
9797
votedLink.votes = createVote.link.votes
98-
cache.writeQuery({ query: FEED_QUERY, data })
98+
store.writeQuery({ query: FEED_QUERY, data })
9999
}
100100

101101
_getQueryVariables = () => {

0 commit comments

Comments
 (0)