Fix gist name.

This commit is contained in:
muzam1l
2022-08-12 15:32:53 +05:30
parent 4b2b4b25c0
commit aa62251780
2 changed files with 5 additions and 3 deletions

View File

@@ -102,7 +102,7 @@ const Navigation = () => {
) : ( ) : (
<> <>
<Heading css={{ lineHeight: 1 }}> <Heading css={{ lineHeight: 1 }}>
{snap.files?.[0]?.name || "XRPL Hooks"} {snap.gistName || "XRPL Hooks"}
</Heading> </Heading>
<Text <Text
css={{ fontSize: "$xs", color: "$mauve10", lineHeight: 1 }} css={{ fontSize: "$xs", color: "$mauve10", lineHeight: 1 }}

View File

@@ -1,6 +1,7 @@
import { Octokit } from "@octokit/core"; import { Octokit } from "@octokit/core";
import state, { IFile } from '../index'; import state, { IFile } from '../index';
import { templateFileIds } from '../constants'; import { templateFileIds } from '../constants';
import { file } from 'jszip';
const octokit = new Octokit(); const octokit = new Octokit();
@@ -74,9 +75,10 @@ export const fetchFiles = async (gistId: string) => {
}); });
state.files = files; state.files = files;
state.gistId = gistId; state.gistId = gistId;
state.gistName = Object.keys(res.data.files)?.[0] || "untitled";
state.gistOwner = res.data.owner?.login; state.gistOwner = res.data.owner?.login;
const gistName = files.find(file => file.language === 'c' || file.language === 'javascript')?.name || "untitled";
state.gistName = gistName
} catch (err) { } catch (err) {
let message: string let message: string
if (err instanceof Error) message = err.message if (err instanceof Error) message = err.message