Skip to content

Commit 127d25c

Browse files
committed
refactor README code
1 parent 0709f5a commit 127d25c

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

README.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,16 @@ const WATCH_REPOSITORY = `
223223
`;
224224
225225
const resolveWatchMutation = (data, state) => {
226-
const { totalCount } = state.data.updateSubscription.subscribable;
226+
const { totalCount } = state.data.repository;
227227
const { viewerSubscription } = data.updateSubscription.subscribable;
228228
229229
return {
230-
updateSubscription: {
231-
subscribable: {
232-
viewerSubscription,
233-
totalCount:
234-
viewerSubscription === 'SUBSCRIBED'
235-
? totalCount + 1
236-
: totalCount - 1,
237-
},
230+
repository: {
231+
viewerSubscription,
232+
totalCount:
233+
viewerSubscription === 'SUBSCRIBED'
234+
? totalCount + 1
235+
: totalCount - 1,
238236
},
239237
};
240238
};
@@ -248,12 +246,10 @@ const Repositories = ({ repositories }) => (
248246
<Mutation
249247
mutation={WATCH_REPOSITORY}
250248
initial={{
251-
updateSubscription: {
252-
subscribable: {
253-
viewerSubscription:
254-
repository.node.viewerSubscription,
255-
totalCount: repository.node.watchers.totalCount,
256-
},
249+
repository: {
250+
viewerSubscription:
251+
repository.node.viewerSubscription,
252+
totalCount: repository.node.watchers.totalCount,
257253
},
258254
}}
259255
resolveMutation={resolveWatchMutation}
@@ -266,16 +262,16 @@ const Repositories = ({ repositories }) => (
266262
variables: {
267263
id: repository.node.id,
268264
viewerSubscription: isWatch(
269-
data.updateSubscription,
265+
data.repository.viewerSubscription,
270266
)
271267
? 'UNSUBSCRIBED'
272268
: 'SUBSCRIBED',
273269
},
274270
})
275271
}
276272
>
277-
{data.updateSubscription.subscribable.totalCount}
278-
{isWatch(data.updateSubscription)
273+
{data.repository.totalCount}
274+
{isWatch(data.repository.viewerSubscription)
279275
? ' Unwatch'
280276
: ' Watch'}
281277
</button>

0 commit comments

Comments
 (0)