Skip to content

Commit

Permalink
Merge pull request #27 from githubnext/jaked/fix_onRequestGitHubData
Browse files Browse the repository at this point in the history
update `onRequestGithubData` call in homepage block
  • Loading branch information
Jake Donham authored Mar 17, 2022
2 parents cb99010 + c243ddc commit 8bdebbf
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
"@excalidraw/excalidraw": "^0.10.0",
"@fullstackio/cq": "^6.0.9",
"@fullstackio/remark-cq": "^6.1.2",
"@githubnext/utils": "^0.18.0",
"@githubnext/utils": "^0.19.3",
"@githubocto/flat-ui": "^0.13.4",
"@loadable/component": "^5.15.0",
"@mdx-js/runtime": "2.0.0-next.9",
Expand Down
7 changes: 3 additions & 4 deletions src/blocks/folder-blocks/homepage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ export default function (props: FolderBlockProps) {
const [isLoading, setIsLoading] = useState(false);

const getSiteUrl = async () => {
const info = await onRequestGitHubData("repo-info", {
owner: props.context.owner,
repo: props.context.repo,
});
const info = await onRequestGitHubData(
"/repos/${props.context.owner}/${props.context.repo}"
);
setUrl(info.homepage);
setIsLoading(false);
};
Expand Down
1 change: 0 additions & 1 deletion src/components/local-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useCallback, useEffect, useState } from "react";
// @ts-ignore
import loadable from "@loadable/component";
import { FileContext, FolderContext, RepoFiles } from "@githubnext/utils";
import { getFileContent, getRepoInfo } from "../hooks";

interface Block {
id: string;
Expand Down
16 changes: 0 additions & 16 deletions src/hooks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,3 @@ export const useLocalStorage = (key: string, initialValue: any) => {

return [storedValue, setValue];
};

export async function getRepoInfo(params: RepoContext): Promise<string> {
const { repo, owner } = params;

const apiUrl = `https://api.github.com/repos/${owner}/${repo}`;

const res = await fetch(apiUrl);
if (res.status !== 200) {
throw new Error(
`Error fetching repo info: ${owner}/${repo}\n${await res.text()}`
);
}

const resObject = await res.json();
return resObject;
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -762,10 +762,10 @@
unist-util-visit "^1.0.0"
uuid "^3.3.2"

"@githubnext/utils@^0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@githubnext/utils/-/utils-0.18.0.tgz#43e5c1909b6cabfe07c85b9c81525ebdbe04d035"
integrity sha512-Xsi7zUDt2vGgrHDvzDLpQWGXdyof65iV7PBWffu/cX/IJKXRG4KJ5zUt7lD7iAXYv4VOgnbmtI81B/ayt2vByQ==
"@githubnext/utils@^0.19.3":
version "0.19.3"
resolved "https://registry.yarnpkg.com/@githubnext/utils/-/utils-0.19.3.tgz#31c535c70454c2a3363de8cea1f8bf0a30a3d556"
integrity sha512-WetjTPpR6nZMUwUNw30RuhOzAdeKCKgPy7Oh5jxRjr/kIKSGfJU7NY3knqqvPk3jD/JjavW0n6AoGWSOL7cvkA==
dependencies:
"@types/lodash.uniqueid" "^4.0.6"
lodash.uniqueid "^4.0.1"
Expand Down

0 comments on commit 8bdebbf

Please sign in to comment.