feat: collection list
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { FeedIcon } from "@renderer/components/feed-icon"
|
||||
import { Image } from "@renderer/components/ui/image"
|
||||
import { useAsRead } from "@renderer/hooks/useAsRead"
|
||||
import dayjs from "@renderer/lib/dayjs"
|
||||
import { cn } from "@renderer/lib/utils"
|
||||
import { useEntry } from "@renderer/store/entry"
|
||||
@@ -10,6 +11,8 @@ import type { UniversalItemProps } from "./types"
|
||||
export function ArticleItem({ entryId, entryPreview }: UniversalItemProps) {
|
||||
const entry = useEntry(entryId) || entryPreview
|
||||
|
||||
const asRead = useAsRead(entry)
|
||||
|
||||
// NOTE: prevent 0 height element, react virtuoso will not stop render any more
|
||||
if (!entry) return <ReactVirtuosoItemPlaceholder />
|
||||
|
||||
@@ -17,7 +20,7 @@ export function ArticleItem({ entryId, entryPreview }: UniversalItemProps) {
|
||||
<div className="flex px-2 py-3">
|
||||
<FeedIcon feed={entry.feeds} entry={entry.entries} />
|
||||
<div className="-mt-0.5 line-clamp-4 flex-1 text-sm leading-tight">
|
||||
<div className={cn("flex gap-1 text-[10px] font-bold", entry.read ? "text-zinc-400" : "text-zinc-500")}>
|
||||
<div className={cn("flex gap-1 text-[10px] font-bold", asRead ? "text-zinc-400" : "text-zinc-500")}>
|
||||
<span className="truncate">{entry.feeds.title}</span>
|
||||
<span>·</span>
|
||||
<span className="shrink-0">
|
||||
@@ -35,7 +38,7 @@ export function ArticleItem({ entryId, entryPreview }: UniversalItemProps) {
|
||||
<i className="i-mingcute-star-fill absolute right-0 top-0.5 text-orange-400" />
|
||||
)}
|
||||
</div>
|
||||
<div className={cn("text-[13px]", entry.read ? "text-zinc-400" : "text-zinc-500")}>
|
||||
<div className={cn("text-[13px]", asRead ? "text-zinc-400" : "text-zinc-500")}>
|
||||
{entry.entries.description}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useAsRead } from "@renderer/hooks/useAsRead"
|
||||
import { useEntryActions } from "@renderer/hooks/useEntryActions"
|
||||
import { views } from "@renderer/lib/constants"
|
||||
import { showNativeMenu } from "@renderer/lib/native-menu"
|
||||
@@ -26,6 +27,8 @@ export function EntryItemWrapper({
|
||||
|
||||
const activeEntry = useFeedStore((state) => state.activeEntry)
|
||||
|
||||
const asRead = useAsRead(entry)
|
||||
|
||||
const read = useMutation({
|
||||
mutationFn: async () =>
|
||||
apiClient.reads.$post({
|
||||
@@ -50,7 +53,7 @@ export function EntryItemWrapper({
|
||||
className={cn(
|
||||
"rounded-md bg-background transition-colors",
|
||||
!views[view || 0].wideMode && activeEntry === entry.entries.id && "bg-theme-item-active",
|
||||
entry.read ? "text-zinc-500/90" : "text-zinc-900 dark:text-white/90",
|
||||
asRead ? "text-zinc-500/90" : "text-zinc-900 dark:text-white/90",
|
||||
)}
|
||||
// ref={ref}
|
||||
onClick={(e) => {
|
||||
|
||||
@@ -85,7 +85,7 @@ export function FeedCategory({
|
||||
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
||||
<div
|
||||
className={cn(
|
||||
"flex w-full items-center justify-between rounded-md px-2.5 py-[2px] text-sm font-medium leading-loose transition-colors",
|
||||
"flex w-full items-center justify-between rounded-md px-2.5 transition-colors",
|
||||
activeList?.level === levels.folder &&
|
||||
activeList.name === data.name &&
|
||||
"bg-native-active",
|
||||
@@ -127,7 +127,7 @@ export function FeedCategory({
|
||||
<div className="flex w-full min-w-0 items-center">
|
||||
<CollapsibleTrigger
|
||||
className={cn(
|
||||
"flex h-7 items-center [&_.i-mingcute-right-fill]:data-[state=open]:rotate-90",
|
||||
"flex h-8 items-center [&_.i-mingcute-right-fill]:data-[state=open]:rotate-90",
|
||||
!setActiveList && "flex-1",
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -147,7 +147,7 @@ export function FeedColumn() {
|
||||
className="shrink-0 snap-center overflow-y-auto"
|
||||
>
|
||||
<FeedList
|
||||
className="flex min-h-full w-64 flex-col px-3 pb-6"
|
||||
className="flex min-h-full w-64 flex-col px-3 pb-6 text-sm"
|
||||
view={index}
|
||||
/>
|
||||
</section>
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { FeedViewType } from "@renderer/lib/enum"
|
||||
import { cn } from "@renderer/lib/utils"
|
||||
import type { FeedListModel, SubscriptionResponse } from "@renderer/models"
|
||||
import { Queries } from "@renderer/queries"
|
||||
import { feedActions, useUnreadStore } from "@renderer/store"
|
||||
import { feedActions, useFeedActiveList, useUnreadStore } from "@renderer/store"
|
||||
import { useMemo, useState } from "react"
|
||||
import { Link } from "react-router-dom"
|
||||
import { parse } from "tldts"
|
||||
@@ -89,6 +89,7 @@ export function FeedList({
|
||||
}) {
|
||||
const [expansion, setExpansion] = useState(false)
|
||||
const data = useData(view)
|
||||
const activeList = useFeedActiveList()
|
||||
|
||||
const totalUnread = useUnreadStore((state) => {
|
||||
let unread = 0
|
||||
@@ -111,7 +112,7 @@ export function FeedList({
|
||||
)
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<div className={cn(className, "font-medium")}>
|
||||
{!hideTitle && (
|
||||
<div
|
||||
className={cn("mb-2 flex items-center justify-between px-2.5 py-1")}
|
||||
@@ -148,6 +149,27 @@ export function FeedList({
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className={cn(
|
||||
"flex h-8 w-full items-center rounded-md px-2.5 transition-colors",
|
||||
activeList?.id === "collections" &&
|
||||
"bg-native-active",
|
||||
)}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
if (view !== undefined) {
|
||||
setActiveList({
|
||||
level: levels.folder,
|
||||
id: "collections",
|
||||
name: "Collections",
|
||||
view,
|
||||
})
|
||||
}
|
||||
}}
|
||||
>
|
||||
<i className="i-mingcute-star-fill mr-2 text-orange-500" />
|
||||
Collections
|
||||
</div>
|
||||
{data?.list?.length ? (
|
||||
sortedByUnread?.map((category) => (
|
||||
<FeedCategory
|
||||
|
||||
@@ -227,8 +227,8 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
|
||||
title: string | null;
|
||||
content: string | null;
|
||||
id: string;
|
||||
url: string | null;
|
||||
feedId: string;
|
||||
url: string | null;
|
||||
guid: string;
|
||||
author: string | null;
|
||||
authorUrl: string | null;
|
||||
@@ -305,6 +305,7 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
|
||||
limit?: number | undefined;
|
||||
feedIdList?: string[] | undefined;
|
||||
publishedAfter?: string | undefined;
|
||||
collected?: boolean | undefined;
|
||||
};
|
||||
};
|
||||
output: {
|
||||
@@ -385,6 +386,9 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
|
||||
title?: string | undefined;
|
||||
}[] | null | undefined;
|
||||
};
|
||||
collections: {
|
||||
createdAt: string;
|
||||
};
|
||||
feeds: {
|
||||
description: string | null;
|
||||
title: string | null;
|
||||
@@ -400,9 +404,6 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
|
||||
errorMessage: string | null;
|
||||
errorAt: string | null;
|
||||
};
|
||||
collections: {
|
||||
createdAt: string;
|
||||
};
|
||||
read: boolean | null;
|
||||
} | undefined;
|
||||
};
|
||||
@@ -424,8 +425,8 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
|
||||
title: string | null;
|
||||
content: string | null;
|
||||
id: string;
|
||||
url: string | null;
|
||||
feedId: string;
|
||||
url: string | null;
|
||||
guid: string;
|
||||
author: string | null;
|
||||
authorUrl: string | null;
|
||||
@@ -459,6 +460,7 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
|
||||
data: {
|
||||
title: string | null;
|
||||
userId: string;
|
||||
feedId: string;
|
||||
feeds: {
|
||||
description: string | null;
|
||||
title: string | null;
|
||||
@@ -474,7 +476,6 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
|
||||
errorMessage: string | null;
|
||||
errorAt: string | null;
|
||||
};
|
||||
feedId: string;
|
||||
view: number;
|
||||
category: string | null;
|
||||
isPrivate: boolean | null;
|
||||
@@ -501,8 +502,8 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
|
||||
$delete: {
|
||||
input: {
|
||||
json: {
|
||||
url?: string | undefined;
|
||||
feedId?: string | undefined;
|
||||
url?: string | undefined;
|
||||
};
|
||||
};
|
||||
output: {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { levels } from "@renderer/lib/constants"
|
||||
import type { EntryModel } from "@renderer/models"
|
||||
import { useFeedStore } from "@renderer/store"
|
||||
|
||||
export function useAsRead(entry: EntryModel) {
|
||||
const activeList = useFeedStore((state) => state.activeList)
|
||||
return entry.read && !(activeList?.level === levels.folder && activeList?.id === "collections")
|
||||
}
|
||||
@@ -117,7 +117,7 @@ export const useEntryActions = ({
|
||||
},
|
||||
{
|
||||
name: "Uncollect",
|
||||
className: "i-mingcute-star-fill",
|
||||
className: "i-mingcute-star-fill text-orange-500",
|
||||
disabled: !entry.collections,
|
||||
onClick: () => {
|
||||
uncollect.mutate()
|
||||
|
||||
@@ -24,9 +24,14 @@ export function getEntriesParams({
|
||||
const params: {
|
||||
feedId?: string
|
||||
feedIdList?: string[]
|
||||
collected?: boolean
|
||||
} = {}
|
||||
if (level === levels.folder) {
|
||||
params.feedIdList = `${id}`.split(",")
|
||||
if (id === "collections") {
|
||||
params.collected = true
|
||||
} else {
|
||||
params.feedIdList = `${id}`.split(",")
|
||||
}
|
||||
} else if (level === levels.feed) {
|
||||
params.feedId = `${id}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user