Skip to content

Commit

Permalink
use incrementing github dependent counter
Browse files Browse the repository at this point in the history
  • Loading branch information
erquhart committed Dec 8, 2024
1 parent 22df36e commit 4eab367
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
20 changes: 16 additions & 4 deletions app/routes/_libraries/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {
} from '@tanstack/react-router'
import { useSuspenseQuery } from '@tanstack/react-query'
import { convexQuery } from '@convex-dev/react-query'
import { useNpmDownloadCounter } from '@erquhart/convex-oss-stats/react'
import {
useNpmDownloadCounter,
useGithubDependentCounter,
} from '@erquhart/convex-oss-stats/react'
import NumberFlow from '@number-flow/react'
import { api } from '../../../convex/_generated/api'
import { Carbon } from '~/components/Carbon'
Expand Down Expand Up @@ -78,8 +81,6 @@ async function bytesSignupServerFn({ email }: { email: string }) {

const librariesRouteApi = getRouteApi('/_libraries')

// Will also be used for GitHub dependent count once
// useGithubDependentCounter is fixed upstream
const StableCounter = ({ value }: { value?: number }) => {
const dummyString = Number(
Array(value?.toString().length ?? 1)
Expand Down Expand Up @@ -117,6 +118,17 @@ const NpmDownloadCounter = ({
return <StableCounter value={liveNpmDownloadCount} />
}

// TODO: Use this once useGithubDependentCounter is fixed upstream
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const GitHubDependentCounter = ({
githubData,
}: {
githubData: Parameters<typeof useGithubDependentCounter>[0]
}) => {
const liveGitHubDependentCount = useGithubDependentCounter(githubData)
return <StableCounter value={liveGitHubDependentCount} />
}

const OssStats = () => {
const { data: github } = useSuspenseQuery(
convexQuery(api.stats.getGithubOwner, {
Expand Down Expand Up @@ -170,7 +182,7 @@ const OssStats = () => {
<FaCube className="text-2xl" />
<div className="">
<div className="text-2xl font-bold opacity-80 relative">
<NumberFlow value={github?.dependentCount} />
<GitHubDependentCounter githubData={github} />
</div>
<div className="text-sm opacity-50 font-medium italic -mt-1">
Dependents on GitHub
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@convex-dev/react-query": "0.0.0-alpha.8",
"@docsearch/css": "^3.5.2",
"@docsearch/react": "^3.5.2",
"@erquhart/convex-oss-stats": "^0.3.1",
"@erquhart/convex-oss-stats": "^0.3.2",
"@headlessui/react": "1.7.18",
"@number-flow/react": "^0.4.1",
"@octokit/graphql": "^7.0.2",
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4eab367

Please sign in to comment.