Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
users = chat.allTimeMembers
participants = users.slice()
// Read-only if not owned by me
if (ownedByMe) {
chatNameState = useState(chat.name)
chatPictureState = useState(chat.picture)
} else {
chatNameState = [chat.name, () => {}]
chatPictureState = [chat.picture, () => {}]
}
const [chatName] = chatNameState
const [chatPicture] = chatPictureState
updateChat = useMutation<
GroupDetailsScreenMutation.Mutation,
GroupDetailsScreenMutation.Variables
>(mutation, {
variables: {
chatId,
name: chatName,
picture: chatPicture,
},
optimisticResponse: {
__typename: 'Mutation',
updateChat: {
...chat,
__typename: 'Chat',
picture: chatPicture,
name: chatName,
},
return user.user
});
// Read-only if not owned by me
if (ownedByMe) {
chatNameState = useState(chat[0].name)
chatPictureState = useState(chat[0].picture)
} else {
chatNameState = [chat[0].name, () => {}]
chatPictureState = [chat[0].picture, () => {}]
}
const [chatName] = chatNameState
const [chatPicture] = chatPictureState
updateChat = useMutation(updateMutation, {
variables: {
chatId,
name: chatName,
picture: chatPicture,
},
update: (client, { data: { update_chat } }) => {
chat[0].picture = update_chat.returning[0].picture
chat[0].name = update_chat.returning[0].name
client.writeFragment({
id: defaultDataIdFromObject(chat),
fragment: fragments.chat,
fragmentName: 'chat',
data: chat,
})
},
export function use(
baseOptions?: ReactApolloHooks.MutationHookOptions,
) {
return ReactApolloHooks.useMutation(
Document,
baseOptions,
)
}
}
export default function useMutationCallback(mutation, baseOptions) {
const [mutate] = useMutation(mutation, baseOptions);
return mutate;
}
export function useCreateMutation(mutation, {
query, queryVariables: variables, arrayPath, newObjectPath, ...options
}) {
const update = useCallback(
createUpdater({
query, variables, arrayPath, newObjectPath,
}),
[query, variables, arrayPath, newObjectPath],
);
const [mutate] = useMutation(mutation, { update, ...options });
return mutate;
}
export function useRegisterMutation(
baseOptions?: ReactApolloHooks.MutationHookOptions,
) {
return ReactApolloHooks.useMutation(RegisterDocument, baseOptions);
}
addStar: {
__typename: "AddStarPayload",
starrable: {
__typename: "Repository",
...repo,
viewerHasStarred: true,
stargazers: {
__typename: "StargazerConnection",
totalCount: repo.stargazers.totalCount + 1
}
}
}
}
});
const removeStar = useMutation(REMOVE_STAR_MUTATION, {
variables: {
repoId: repo.id
},
optimisticResponse: {
removeStar: {
__typename: "RemoveStarPayload",
starrable: {
...repo,
viewerHasStarred: false,
stargazers: {
__typename: "StargazerConnection",
totalCount: repo.stargazers.totalCount - 1
},
__typename: "Repository"
}
}
export default function Repository({ repo }) {
const addStar = useMutation(ADD_STAR_MUTATION, {
variables: {
repoId: repo.id
},
optimisticResponse: {
addStar: {
__typename: "AddStarPayload",
starrable: {
__typename: "Repository",
...repo,
viewerHasStarred: true,
stargazers: {
__typename: "StargazerConnection",
totalCount: repo.stargazers.totalCount + 1
}
}
}
export default withRouter(({ match: { params: { username } } }) => {
const { data, loading } = useQuery(GET_USER, { variables: { username } });
const logOut = useMutation(LOG_OUT);
return ;
});
export const CardsContainer: React.FC = () => {
const { data, loading } = useQuery(UsersQuery)
const like = useMutation(LikeMutation)
const dislike = useMutation(DislikeMutation)
if (loading) return <p>loading</p>
return
}