Skip to content

Commit

Permalink
feat: optional types
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed May 14, 2024
1 parent 2d30d71 commit 95718d6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
18 changes: 10 additions & 8 deletions src/renderer/src/components/feed-summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,34 @@ export function FollowSummary({
feed,
docs,
}: {
feed: Partial<FeedResponse>
feed: FeedResponse
docs?: string
}) {
return (
<div className="select-text text-sm space-y-1">
<div className="select-text text-sm space-y-1 max-w-[462px]">
<a href={feed.siteUrl} target="_blank" className="flex items-center">
{(() => {
if (feed.image) {
return <Image src={feed.image} className="w-8 h-8 mr-2" />
return <Image src={feed.image} className="w-8 h-8 mr-2 shrink-0" />
} else if (feed.siteUrl) {
return <SiteIcon url={feed.siteUrl} className="w-8 h-8" />
return <SiteIcon url={feed.siteUrl} className="w-8 h-8 shrink-0" />
} else if (docs) {
return <SiteIcon url="https://rsshub.app" className="w-8 h-8" />
return (
<SiteIcon url="https://rsshub.app" className="w-8 h-8 shrink-0" />
)
} else {
return null
}
})()}
<div className="leading-tight font-semibold text-base">
<div className="leading-tight font-semibold text-base truncate">
{feed.title}
<div className="font-normal truncate text-xs text-zinc-500">
{feed.description}
</div>
</div>
</a>
<div className="text-zinc-500 flex items-center gap-1">
<i className="i-mingcute-right-line" />
<div className="text-zinc-500 flex items-center gap-1 truncate">
<i className="i-mingcute-right-line shrink-0" />
{feed.url || docs}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/follow/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function FollowForm({ type }: { type: string }) {
mutationFn: async (keyword: string) => {
const { data } = await apiFetch<{
data: {
feed: Partial<FeedResponse>
feed: FeedResponse
docs?: string
entries?: Partial<EntriesResponse>
isSubscribed?: boolean
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/src/components/site-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ export function SiteIcon({
url,
className,
}: {
url: string
url?: string
className?: string
}) {
let host
let src
let fallback

if (!url) return null

try {
host = new URL(url).host
const pureDomain = parse(host).domainWithoutSuffix
Expand Down
16 changes: 8 additions & 8 deletions src/renderer/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ export type ActivedList = {
export type FeedResponse = {
id: string
url: string
title: string
description: string
siteUrl: string
image: string
title?: string
description?: string
siteUrl?: string
image?: string
checkedAt: string
nextCheckAt: string
lastModifiedHeader: string
etagHeader: string
lastModifiedHeader?: string
etagHeader?: string
ttl: number
}

export type SubscriptionResponse = {
userId: string
feedId: string
view: number
category: string
title: string
category?: string
title?: string
unread?: number
feeds: FeedResponse
}[]
Expand Down

0 comments on commit 95718d6

Please sign in to comment.