Skip to content

Commit 8f682a3

Browse files
Type fixes
1 parent c3d5993 commit 8f682a3

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

src/routes/[pullOrIssue=poi]/[org]/[repo]/[id=number]/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import type { Issue, Repository } from "@octokit/graphql-schema";
33
import { LoaderCircle } from "lucide-svelte";
44
import { getOctokit } from "$lib/octokit";
5-
import type { Issues, Pulls } from "./types";
5+
import type { Issues, LinkedEntity, Pulls } from "./types";
66
import PageRenderer from "./PageRenderer.svelte";
77
88
let { data } = $props();
@@ -48,7 +48,7 @@
4848
}
4949
5050
// PR issues or issue PRs
51-
let linkedPRsOrIssues = $state<(Issue | Awaited<ReturnType<Pulls["get"]>>["data"])[]>();
51+
let linkedPRsOrIssues = $state<LinkedEntity[]>();
5252
5353
// PR
5454
let prInfo = $state<{

src/routes/[pullOrIssue=poi]/[org]/[repo]/[id=number]/BottomCollapsible.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</script>
2424

2525
<div class="rounded-xl border px-4">
26-
<Accordion.Root value={openByDefault ? key : undefined}>
26+
<Accordion.Root type="single" value={openByDefault ? key : undefined}>
2727
<Accordion.Item value={key} class="border-b-0">
2828
<Accordion.Trigger
2929
class="group hover:no-underline [&>svg:last-child]:flex-shrink-0 [&[data-state=open]>svg:last-child]:rotate-180 [&[data-state=open]>svg]:rotate-0"

src/routes/[pullOrIssue=poi]/[org]/[repo]/[id=number]/PageRenderer.svelte

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@
7373
let repo = $derived(info.html_url?.replace("https://github.com/", "").split("/")[1] ?? "");
7474
let type = $derived.by(() => {
7575
if (!info.html_url) return "issue" as const;
76-
return (
77-
info.html_url.replace("https://github.com/", "").split("/")[2] === "pull" ? "pull" : "issue"
78-
) as const;
76+
return info.html_url.replace("https://github.com/", "").split("/")[2] === "pull"
77+
? ("pull" as const)
78+
: ("issue" as const);
7979
});
8080
8181
let rightPartInfo = $derived.by(() => {
@@ -125,7 +125,7 @@
125125
<h3 class="text-2xl font-semibold tracking-tight">
126126
{type === "pull" ? "Closing issue" : "Development PR"}{linkedEntities.length > 1 ? "s" : ""}
127127
</h3>
128-
<Accordion.Root class="mb-12">
128+
<Accordion.Root type="single" class="mb-12">
129129
{#each linkedEntities as entity}
130130
<Accordion.Item value={entity.number.toString()}>
131131
<Accordion.Trigger class="group hover:no-underline [&>svg:last-child]:flex-shrink-0">
@@ -145,24 +145,28 @@
145145
<div
146146
class="mr-4 flex flex-shrink-0 flex-col items-end gap-1 text-right text-sm text-muted-foreground xs:ml-auto xs:flex-row xs:items-center"
147147
>
148-
<div class="flex items-center gap-2">
149-
<Avatar.Root class="size-6">
150-
<Avatar.Image src={entity.author.avatarUrl} alt={entity.author.login} />
151-
<Avatar.Fallback>
152-
{entity.author.login.charAt(0).toUpperCase()}
153-
</Avatar.Fallback>
154-
</Avatar.Root>
155-
<span class="font-semibold">{entity.author.login}</span>
156-
</div>
157-
<span class="hidden xs:block">•</span>
158-
<span>{formatToDateTime(entity.createdAt)}</span>
148+
{#if "author" in entity}
149+
<div class="flex items-center gap-2">
150+
<Avatar.Root class="size-6">
151+
<Avatar.Image src={entity.author?.avatarUrl} alt={entity.author?.login} />
152+
<Avatar.Fallback>
153+
{entity.author?.login.charAt(0).toUpperCase()}
154+
</Avatar.Fallback>
155+
</Avatar.Root>
156+
<span class="font-semibold">{entity.author?.login}</span>
157+
</div>
158+
<span class="hidden xs:block">•</span>
159+
{/if}
160+
{#if "createdAt" in entity}
161+
<span>{formatToDateTime(entity.createdAt)}</span>
162+
{/if}
159163
</div>
160164
</div>
161165
</Accordion.Trigger>
162166
<!-- Body -->
163167
<Accordion.Content class="mx-auto sm:w-3/4">
164168
<MarkdownRenderer
165-
markdown={entity.body}
169+
markdown={entity.body || "_No description provided_"}
166170
parseRawHtml
167171
class="max-w-full text-base"
168172
additionalPlugins={[shikiPlugin]}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import type { Octokit } from "octokit";
2+
import type { Issue } from "@octokit/graphql-schema";
3+
4+
export type LinkedEntity = Issue | Awaited<ReturnType<Pulls["get"]>>["data"];
25

36
export type Issues = InstanceType<typeof Octokit>["rest"]["issues"];
47
export type Pulls = InstanceType<typeof Octokit>["rest"]["pulls"];

0 commit comments

Comments
 (0)