Refactored instant loading and some other components

This commit is contained in:
squidfunk
2021-02-12 12:12:49 +01:00
parent 884330da3b
commit 9c9ea8a64d
33 changed files with 463 additions and 150 deletions

View File

@@ -24,7 +24,7 @@ import { Repo, User } from "github-types"
import { Observable } from "rxjs"
import { defaultIfEmpty, map } from "rxjs/operators"
import { fetchJSON } from "~/browser"
import { requestJSON } from "~/browser"
import { round } from "~/utilities"
import { SourceFacts } from "../_"
@@ -47,7 +47,7 @@ export function fetchSourceFactsFromGitHub(
const url = typeof repo !== "undefined"
? `https://api.github.com/repos/${user}/${repo}`
: `https://api.github.com/users/${user}`
return fetchJSON<Repo & User>(url)
return requestJSON<Repo & User>(url)
.pipe(
map(data => {

View File

@@ -24,7 +24,7 @@ import { ProjectSchema } from "gitlab"
import { Observable } from "rxjs"
import { defaultIfEmpty, map } from "rxjs/operators"
import { fetchJSON } from "~/browser"
import { requestJSON } from "~/browser"
import { round } from "~/utilities"
import { SourceFacts } from "../_"
@@ -45,7 +45,7 @@ export function fetchSourceFactsFromGitLab(
base: string, project: string
): Observable<SourceFacts> {
const url = `https://${base}/api/v4/projects/${encodeURIComponent(project)}`
return fetchJSON<ProjectSchema>(url)
return requestJSON<ProjectSchema>(url)
.pipe(
map(({ star_count, forks_count }) => ([
`${round(star_count)} Stars`,