Download spectrum/api/queries/channel/memberCount.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 457 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/channel/memberCount.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/api/queries/channel/memberCount.js
-
curl -L -o memberCount.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/channel/memberCount.js
457 Bytes
| // @flow | |
| import type { DBChannel } from 'shared/types'; | |
| import type { GraphQLContext } from '../../'; | |
| import { canViewChannel } from '../../utils/permissions'; | |
| export default async (channel: DBChannel, _: any, ctx: GraphQLContext) => { | |
| const { id, memberCount, isPrivate } = channel; | |
| const { loaders, user: currentUser } = ctx; | |
| if (isPrivate) { | |
| if (!(await canViewChannel(currentUser, id, loaders))) return 0; | |
| } | |
| return memberCount || 1; | |
| }; | |