feat: feed category and item component
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
import { useState } from "react"
|
||||
import {
|
||||
ContextMenu,
|
||||
ContextMenuContent,
|
||||
ContextMenuItem,
|
||||
ContextMenuTrigger,
|
||||
} from "@renderer/components/ui/context-menu"
|
||||
import { Dialog, DialogTrigger } from "@renderer/components/ui/dialog"
|
||||
import { CategoryRenameDialog } from "./category-rename-dialog"
|
||||
import { CategoryRemoveDialog } from "./category-remove-dialog"
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogTrigger,
|
||||
} from "@renderer/components/ui/alert-dialog"
|
||||
|
||||
export function CategoryContextMenu({
|
||||
name,
|
||||
view,
|
||||
children,
|
||||
onOpenChange,
|
||||
feedIdList,
|
||||
}: {
|
||||
name: string
|
||||
view?: number
|
||||
children: React.ReactNode
|
||||
onOpenChange?: (open: boolean) => void
|
||||
feedIdList: string[]
|
||||
}) {
|
||||
const [dialogOpen, setDialogOpen] = useState(false)
|
||||
|
||||
return (
|
||||
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
||||
<AlertDialog>
|
||||
<ContextMenu onOpenChange={(open) => onOpenChange?.(open)}>
|
||||
<ContextMenuTrigger className="w-full">{children}</ContextMenuTrigger>
|
||||
<ContextMenuContent onClick={(e) => e.stopPropagation()}>
|
||||
<DialogTrigger asChild>
|
||||
<ContextMenuItem>Rename Category</ContextMenuItem>
|
||||
</DialogTrigger>
|
||||
<AlertDialogTrigger>
|
||||
<ContextMenuItem>Remove Category</ContextMenuItem>
|
||||
</AlertDialogTrigger>
|
||||
</ContextMenuContent>
|
||||
</ContextMenu>
|
||||
<CategoryRenameDialog
|
||||
feedIdList={feedIdList}
|
||||
view={view}
|
||||
category={name}
|
||||
onSuccess={() => setDialogOpen(false)}
|
||||
/>
|
||||
<CategoryRemoveDialog
|
||||
feedIdList={feedIdList}
|
||||
view={view}
|
||||
category={name}
|
||||
onSuccess={() => setDialogOpen(false)}
|
||||
/>
|
||||
</AlertDialog>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
import {
|
||||
Collapsible,
|
||||
CollapsibleTrigger,
|
||||
} from "@renderer/components/ui/collapsible"
|
||||
import { m, AnimatePresence } from "framer-motion"
|
||||
import { useEffect, useState } from "react"
|
||||
import { levels } from "@renderer/lib/constants"
|
||||
import { ActivedList } from "@renderer/lib/types"
|
||||
import { cn } from "@renderer/lib/utils"
|
||||
import { Response as SubscriptionsResponse } from "@renderer/lib/queries/subscriptions"
|
||||
import { showNativeMenu } from "@renderer/lib/native-menu"
|
||||
import { client } from "@renderer/lib/client"
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
||||
import { apiFetch } from "@renderer/lib/queries/api-fetch"
|
||||
import { CategoryRenameDialog } from "./category-rename-dialog"
|
||||
import { Dialog } from "@renderer/components/ui/dialog"
|
||||
import { FeedItem } from "./item"
|
||||
|
||||
export function FeedCategory({
|
||||
data,
|
||||
activedList,
|
||||
setActivedList,
|
||||
view,
|
||||
expansion,
|
||||
}: {
|
||||
data: SubscriptionsResponse["list"][number]
|
||||
activedList?: ActivedList
|
||||
setActivedList?: (value: ActivedList) => void
|
||||
view?: number
|
||||
expansion: boolean
|
||||
}) {
|
||||
const [open, setOpen] = useState(!data.name)
|
||||
const [dialogOpen, setDialogOpen] = useState(false)
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const feedIdList = data.list.map((feed) => feed.feedId)
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: async () =>
|
||||
apiFetch("/categories", {
|
||||
method: "DELETE",
|
||||
body: {
|
||||
feedIdList,
|
||||
deleteSubscriptions: false,
|
||||
},
|
||||
}),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["subscriptions", view],
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (data.name) {
|
||||
setOpen(expansion)
|
||||
}
|
||||
}, [expansion])
|
||||
|
||||
const setCatrgoryActive = () => {
|
||||
view !== undefined &&
|
||||
setActivedList?.({
|
||||
level: levels.folder,
|
||||
id: data.list.map((feed) => feed.feedId).join(","),
|
||||
name: data.name,
|
||||
view,
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<Collapsible
|
||||
open={open}
|
||||
onOpenChange={(o) => setOpen(o)}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{!!data.name && (
|
||||
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center justify-between font-medium text-sm leading-loose px-2.5 py-[2px] rounded-md w-full transition-colors",
|
||||
activedList?.level === levels.folder &&
|
||||
activedList.name === data.name &&
|
||||
"bg-[#C9C9C7]",
|
||||
)}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setCatrgoryActive()
|
||||
}}
|
||||
onContextMenu={(e) => {
|
||||
showNativeMenu(
|
||||
[
|
||||
{
|
||||
type: "text",
|
||||
label: "Rename Category",
|
||||
click: () => setDialogOpen(true),
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
label: "Delete Category",
|
||||
click: async () => {
|
||||
if (
|
||||
await client.showConfirmDialog({
|
||||
title: `Delete Category ${data.name}?`,
|
||||
message: `This operation will delete your category, but the feeds it contains will be retained and grouped by website.`,
|
||||
options: {
|
||||
buttons: ["Delete", "Cancel"],
|
||||
},
|
||||
})
|
||||
) {
|
||||
deleteMutation.mutate()
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
e,
|
||||
)
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center min-w-0 w-full">
|
||||
<CollapsibleTrigger
|
||||
className={cn(
|
||||
"flex items-center h-7 [&_.i-mingcute-right-fill]:data-[state=open]:rotate-90",
|
||||
!setActivedList && "flex-1",
|
||||
)}
|
||||
>
|
||||
<i className="i-mingcute-right-fill mr-2 transition-transform" />
|
||||
{!setActivedList && (
|
||||
<span className="truncate">{data.name}</span>
|
||||
)}
|
||||
</CollapsibleTrigger>
|
||||
{setActivedList && <span className="truncate">{data.name}</span>}
|
||||
</div>
|
||||
{!!data.unread && (
|
||||
<div className="text-xs text-zinc-500 ml-2">{data.unread}</div>
|
||||
)}
|
||||
<CategoryRenameDialog
|
||||
feedIdList={feedIdList}
|
||||
view={view}
|
||||
category={data.name}
|
||||
onSuccess={() => setDialogOpen(false)}
|
||||
/>
|
||||
</div>
|
||||
</Dialog>
|
||||
)}
|
||||
<AnimatePresence>
|
||||
{open && (
|
||||
<m.div
|
||||
className="overflow-hidden"
|
||||
initial={
|
||||
!!data.name && {
|
||||
height: 0,
|
||||
opacity: 0.01,
|
||||
}
|
||||
}
|
||||
animate={{
|
||||
height: "auto",
|
||||
opacity: 1,
|
||||
}}
|
||||
exit={{
|
||||
height: 0,
|
||||
opacity: 0.01,
|
||||
}}
|
||||
>
|
||||
{data.list.map((feed) => (
|
||||
<FeedItem
|
||||
key={feed.feedId}
|
||||
feed={feed}
|
||||
activedList={activedList}
|
||||
setActivedList={setActivedList}
|
||||
view={view}
|
||||
className={!!data.name ? "pl-6" : "pl-2.5"}
|
||||
/>
|
||||
))}
|
||||
</m.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</Collapsible>
|
||||
)
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
import { useState } from "react"
|
||||
import {
|
||||
ContextMenu,
|
||||
ContextMenuContent,
|
||||
ContextMenuItem,
|
||||
ContextMenuTrigger,
|
||||
ContextMenuSeparator,
|
||||
} from "@renderer/components/ui/context-menu"
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
||||
import { useToast } from "@renderer/components/ui/use-toast"
|
||||
import { ToastAction } from "@renderer/components/ui/toast"
|
||||
import { SubscriptionResponse } from "@renderer/lib/types"
|
||||
import { apiFetch } from "@renderer/lib/queries/api-fetch"
|
||||
import { FollowDialog } from "@renderer/components/follow/dialog"
|
||||
import { Dialog, DialogTrigger } from "@renderer/components/ui/dialog"
|
||||
|
||||
export function FeedContextMenu({
|
||||
feed,
|
||||
children,
|
||||
onOpenChange,
|
||||
}: {
|
||||
feed: SubscriptionResponse[number]
|
||||
children: React.ReactNode
|
||||
onOpenChange?: (open: boolean) => void
|
||||
}) {
|
||||
const [dialogOpen, setDialogOpen] = useState(false)
|
||||
const { toast } = useToast()
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: async (feed: SubscriptionResponse[number]) =>
|
||||
apiFetch("/subscriptions", {
|
||||
method: "DELETE",
|
||||
body: {
|
||||
feedId: feed.feedId,
|
||||
},
|
||||
}),
|
||||
onSuccess: (_, variables) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["subscriptions", feed.view],
|
||||
})
|
||||
toast({
|
||||
duration: 3000,
|
||||
description: (
|
||||
<>
|
||||
Feed <i className="font-semibold mr-px">{variables.feeds.title}</i>{" "}
|
||||
has been unfollowed.
|
||||
</>
|
||||
),
|
||||
action: (
|
||||
<ToastAction
|
||||
altText="Undo"
|
||||
onClick={async () => {
|
||||
await apiFetch("/subscriptions", {
|
||||
method: "POST",
|
||||
body: {
|
||||
url: variables.feeds.url,
|
||||
view: feed.view,
|
||||
category: variables.category,
|
||||
isPrivate: variables.isPrivate,
|
||||
},
|
||||
})
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["subscriptions", feed.view],
|
||||
})
|
||||
}}
|
||||
>
|
||||
Undo
|
||||
</ToastAction>
|
||||
),
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
return (
|
||||
<Dialog key={feed.feedId} open={dialogOpen} onOpenChange={setDialogOpen}>
|
||||
<ContextMenu onOpenChange={(open) => onOpenChange?.(open)}>
|
||||
<ContextMenuTrigger>{children}</ContextMenuTrigger>
|
||||
<ContextMenuContent onClick={(e) => e.stopPropagation()}>
|
||||
<DialogTrigger asChild>
|
||||
<ContextMenuItem>Edit</ContextMenuItem>
|
||||
</DialogTrigger>
|
||||
<ContextMenuItem onClick={() => deleteMutation.mutate(feed)}>
|
||||
Unfollow
|
||||
</ContextMenuItem>
|
||||
<ContextMenuSeparator />
|
||||
<ContextMenuItem>Open Feed in Browser</ContextMenuItem>
|
||||
<ContextMenuItem onClick={() => window.open(feed.feeds.siteUrl)}>
|
||||
Open Site in Browser
|
||||
</ContextMenuItem>
|
||||
</ContextMenuContent>
|
||||
</ContextMenu>
|
||||
<FollowDialog
|
||||
feed={feed}
|
||||
onSuccess={() => setDialogOpen(false)}
|
||||
isSubscribed={true}
|
||||
/>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
import { useState } from "react"
|
||||
import { levels } from "@renderer/lib/constants"
|
||||
import { ActivedList, SubscriptionResponse } from "@renderer/lib/types"
|
||||
import { cn } from "@renderer/lib/utils"
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
TooltipPortal,
|
||||
} from "@renderer/components/ui/tooltip"
|
||||
import { FeedIcon } from "@renderer/components/feed-icon"
|
||||
import dayjs from "@renderer/lib/dayjs"
|
||||
import { showNativeMenu } from "@renderer/lib/native-menu"
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
||||
import { apiFetch } from "@renderer/lib/queries/api-fetch"
|
||||
import { Dialog } from "@renderer/components/ui/dialog"
|
||||
import { FollowDialog } from "@renderer/components/follow/dialog"
|
||||
import { useToast } from "@renderer/components/ui/use-toast"
|
||||
import { ToastAction } from "@renderer/components/ui/toast"
|
||||
|
||||
export function FeedItem({
|
||||
feed,
|
||||
activedList,
|
||||
setActivedList,
|
||||
view,
|
||||
className,
|
||||
}: {
|
||||
feed: SubscriptionResponse[number]
|
||||
activedList?: ActivedList
|
||||
setActivedList?: (value: ActivedList) => void
|
||||
view?: number
|
||||
className?: string
|
||||
}) {
|
||||
const [dialogOpen, setDialogOpen] = useState(false)
|
||||
|
||||
const setFeedActive = (feed: SubscriptionResponse[number]) => {
|
||||
view !== undefined &&
|
||||
setActivedList?.({
|
||||
level: levels.feed,
|
||||
id: feed.feedId,
|
||||
name: feed.feeds.title || "",
|
||||
view,
|
||||
})
|
||||
}
|
||||
|
||||
const { toast } = useToast()
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: async (feed: SubscriptionResponse[number]) =>
|
||||
apiFetch("/subscriptions", {
|
||||
method: "DELETE",
|
||||
body: {
|
||||
feedId: feed.feedId,
|
||||
},
|
||||
}),
|
||||
onSuccess: (_, variables) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["subscriptions", feed.view],
|
||||
})
|
||||
toast({
|
||||
duration: 3000,
|
||||
description: (
|
||||
<>
|
||||
Feed <i className="font-semibold mr-px">{variables.feeds.title}</i>{" "}
|
||||
has been unfollowed.
|
||||
</>
|
||||
),
|
||||
action: (
|
||||
<ToastAction
|
||||
altText="Undo"
|
||||
onClick={async () => {
|
||||
await apiFetch("/subscriptions", {
|
||||
method: "POST",
|
||||
body: {
|
||||
url: variables.feeds.url,
|
||||
view: feed.view,
|
||||
category: variables.category,
|
||||
isPrivate: variables.isPrivate,
|
||||
},
|
||||
})
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["subscriptions", feed.view],
|
||||
})
|
||||
}}
|
||||
>
|
||||
Undo
|
||||
</ToastAction>
|
||||
),
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
return (
|
||||
<Dialog key={feed.feedId} open={dialogOpen} onOpenChange={setDialogOpen}>
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center justify-between text-sm font-medium leading-loose w-full pr-2.5 py-[2px] rounded-md",
|
||||
activedList?.level === levels.feed &&
|
||||
activedList.id === feed.feedId &&
|
||||
"bg-[#C9C9C7]",
|
||||
className,
|
||||
)}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setFeedActive(feed)
|
||||
}}
|
||||
onContextMenu={(e) => {
|
||||
showNativeMenu(
|
||||
[
|
||||
{
|
||||
type: "text",
|
||||
label: "Edit",
|
||||
click: () => setDialogOpen(true),
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
label: "Unfollow",
|
||||
click: () => deleteMutation.mutate(feed),
|
||||
},
|
||||
{
|
||||
type: "separator",
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
label: "Open Feed in Browser",
|
||||
click: () => {
|
||||
// TODO
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
label: "Open Site in Browser",
|
||||
click: () => window.open(feed.feeds.siteUrl),
|
||||
},
|
||||
],
|
||||
e,
|
||||
)
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center min-w-0",
|
||||
feed.feeds.errorAt && "text-red-900",
|
||||
)}
|
||||
>
|
||||
<FeedIcon feed={feed.feeds} className="w-4 h-4" />
|
||||
<div className="truncate">{feed.feeds.title}</div>
|
||||
{feed.feeds.errorAt && (
|
||||
<TooltipProvider delayDuration={300}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<i className="i-mingcute-wifi-off-line shrink-0 ml-1 text-base" />
|
||||
</TooltipTrigger>
|
||||
<TooltipPortal>
|
||||
<TooltipContent>
|
||||
Error since{" "}
|
||||
{dayjs
|
||||
.duration(
|
||||
dayjs(feed.feeds.errorAt).diff(dayjs(), "minute"),
|
||||
"minute",
|
||||
)
|
||||
.humanize(true)}
|
||||
</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
)}
|
||||
{feed.isPrivate && (
|
||||
<TooltipProvider delayDuration={300}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<i className="i-mingcute-eye-close-line shrink-0 ml-1 text-base" />
|
||||
</TooltipTrigger>
|
||||
<TooltipPortal>
|
||||
<TooltipContent>
|
||||
Not publicly visible on your profile page
|
||||
</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
)}
|
||||
</div>
|
||||
{!!feed.unread && (
|
||||
<div className="text-xs text-zinc-500 ml-2">{feed.unread}</div>
|
||||
)}
|
||||
<FollowDialog
|
||||
feed={feed}
|
||||
onSuccess={() => setDialogOpen(false)}
|
||||
isSubscribed={true}
|
||||
/>
|
||||
</div>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@@ -1,29 +1,9 @@
|
||||
import { useSubscriptions } from "@renderer/lib/queries/subscriptions"
|
||||
import {
|
||||
Collapsible,
|
||||
CollapsibleTrigger,
|
||||
} from "@renderer/components/ui/collapsible"
|
||||
import { m, AnimatePresence } from "framer-motion"
|
||||
import { useEffect, useState } from "react"
|
||||
import { levels, views } from "@renderer/lib/constants"
|
||||
import { ActivedList, SubscriptionResponse } from "@renderer/lib/types"
|
||||
import { useState } from "react"
|
||||
import { views } from "@renderer/lib/constants"
|
||||
import { ActivedList } from "@renderer/lib/types"
|
||||
import { cn } from "@renderer/lib/utils"
|
||||
import { Response as SubscriptionsResponse } from "@renderer/lib/queries/subscriptions"
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
TooltipPortal,
|
||||
} from "@renderer/components/ui/tooltip"
|
||||
import { FeedIcon } from "@renderer/components/feed-icon"
|
||||
import dayjs from "@renderer/lib/dayjs"
|
||||
import { showNativeMenu } from "@renderer/lib/native-menu"
|
||||
import { client } from "@renderer/lib/client"
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
||||
import { apiFetch } from "@renderer/lib/queries/api-fetch"
|
||||
import { CategoryRenameDialog } from "./category-rename-dialog"
|
||||
import { Dialog } from "../ui/dialog"
|
||||
import { FeedCategory } from "./category"
|
||||
|
||||
export function FeedList({
|
||||
className,
|
||||
@@ -79,261 +59,3 @@ export function FeedList({
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function FeedCategory({
|
||||
data,
|
||||
activedList,
|
||||
setActivedList,
|
||||
view,
|
||||
expansion,
|
||||
}: {
|
||||
data: SubscriptionsResponse["list"][number]
|
||||
activedList?: ActivedList
|
||||
setActivedList?: (value: ActivedList) => void
|
||||
view?: number
|
||||
expansion: boolean
|
||||
}) {
|
||||
const [open, setOpen] = useState(!data.name)
|
||||
const [dialogOpen, setDialogOpen] = useState(false)
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const feedIdList = data.list.map((feed) => feed.feedId)
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: async () =>
|
||||
apiFetch("/categories", {
|
||||
method: "DELETE",
|
||||
body: {
|
||||
feedIdList,
|
||||
deleteSubscriptions: false,
|
||||
},
|
||||
}),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["subscriptions", view],
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
const setFeedActive = (feed: SubscriptionResponse[number]) => {
|
||||
view !== undefined &&
|
||||
setActivedList?.({
|
||||
level: levels.feed,
|
||||
id: feed.feedId,
|
||||
name: feed.feeds.title || "",
|
||||
view,
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (data.name) {
|
||||
setOpen(expansion)
|
||||
}
|
||||
}, [expansion])
|
||||
|
||||
const setCatrgoryActive = () => {
|
||||
view !== undefined &&
|
||||
setActivedList?.({
|
||||
level: levels.folder,
|
||||
id: data.list.map((feed) => feed.feedId).join(","),
|
||||
name: data.name,
|
||||
view,
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<Collapsible
|
||||
open={open}
|
||||
onOpenChange={(o) => setOpen(o)}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{!!data.name && (
|
||||
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center justify-between font-medium text-sm leading-loose px-2.5 py-[2px] rounded-md w-full transition-colors",
|
||||
activedList?.level === levels.folder &&
|
||||
activedList.name === data.name &&
|
||||
"bg-[#C9C9C7]",
|
||||
)}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setCatrgoryActive()
|
||||
}}
|
||||
onContextMenu={(e) => {
|
||||
showNativeMenu(
|
||||
[
|
||||
{
|
||||
type: "text",
|
||||
label: "Rename Category",
|
||||
click: () => setDialogOpen(true),
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
label: "Delete Category",
|
||||
click: async () => {
|
||||
if (
|
||||
await client.showConfirmDialog({
|
||||
title: `Delete Category ${data.name}?`,
|
||||
message: `This operation will delete your category, but the feeds it contains will be retained and grouped by website.`,
|
||||
options: {
|
||||
buttons: ["Delete", "Cancel"],
|
||||
},
|
||||
})
|
||||
) {
|
||||
deleteMutation.mutate()
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
e,
|
||||
)
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center min-w-0 w-full">
|
||||
<CollapsibleTrigger
|
||||
className={cn(
|
||||
"flex items-center h-7 [&_.i-mingcute-right-fill]:data-[state=open]:rotate-90",
|
||||
!setActivedList && "flex-1",
|
||||
)}
|
||||
>
|
||||
<i className="i-mingcute-right-fill mr-2 transition-transform" />
|
||||
{!setActivedList && (
|
||||
<span className="truncate">{data.name}</span>
|
||||
)}
|
||||
</CollapsibleTrigger>
|
||||
{setActivedList && <span className="truncate">{data.name}</span>}
|
||||
</div>
|
||||
{!!data.unread && (
|
||||
<div className="text-xs text-zinc-500 ml-2">{data.unread}</div>
|
||||
)}
|
||||
<CategoryRenameDialog
|
||||
feedIdList={feedIdList}
|
||||
view={view}
|
||||
category={data.name}
|
||||
onSuccess={() => setDialogOpen(false)}
|
||||
/>
|
||||
</div>
|
||||
</Dialog>
|
||||
)}
|
||||
<AnimatePresence>
|
||||
{open && (
|
||||
<m.div
|
||||
className="overflow-hidden"
|
||||
initial={
|
||||
!!data.name && {
|
||||
height: 0,
|
||||
opacity: 0.01,
|
||||
}
|
||||
}
|
||||
animate={{
|
||||
height: "auto",
|
||||
opacity: 1,
|
||||
}}
|
||||
exit={{
|
||||
height: 0,
|
||||
opacity: 0.01,
|
||||
}}
|
||||
>
|
||||
{data.list.map((feed) => (
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center justify-between text-sm font-medium leading-loose w-full pr-2.5 py-[2px] rounded-md",
|
||||
activedList?.level === levels.feed &&
|
||||
activedList.id === feed.feedId &&
|
||||
"bg-[#C9C9C7]",
|
||||
!!data.name ? "pl-6" : "pl-2.5",
|
||||
)}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setFeedActive(feed)
|
||||
}}
|
||||
onContextMenu={(e) => {
|
||||
showNativeMenu(
|
||||
[
|
||||
{
|
||||
type: "text",
|
||||
label: "Edit",
|
||||
click: async () => {},
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
label: "Unfollow",
|
||||
click: async () => {},
|
||||
},
|
||||
{
|
||||
type: "separator",
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
label: "Open Feed in Browser",
|
||||
click: async () => {},
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
label: "Open Site in Browser",
|
||||
click: () => window.open(feed.feeds.siteUrl),
|
||||
},
|
||||
],
|
||||
e,
|
||||
)
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center min-w-0",
|
||||
feed.feeds.errorAt && "text-red-900",
|
||||
)}
|
||||
>
|
||||
<FeedIcon feed={feed.feeds} className="w-4 h-4" />
|
||||
<div className="truncate">{feed.feeds.title}</div>
|
||||
{feed.feeds.errorAt && (
|
||||
<TooltipProvider delayDuration={300}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<i className="i-mingcute-wifi-off-line shrink-0 ml-1 text-base" />
|
||||
</TooltipTrigger>
|
||||
<TooltipPortal>
|
||||
<TooltipContent>
|
||||
Error since{" "}
|
||||
{dayjs
|
||||
.duration(
|
||||
dayjs(feed.feeds.errorAt).diff(
|
||||
dayjs(),
|
||||
"minute",
|
||||
),
|
||||
"minute",
|
||||
)
|
||||
.humanize(true)}
|
||||
</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
)}
|
||||
{feed.isPrivate && (
|
||||
<TooltipProvider delayDuration={300}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<i className="i-mingcute-eye-close-line shrink-0 ml-1 text-base" />
|
||||
</TooltipTrigger>
|
||||
<TooltipPortal>
|
||||
<TooltipContent>
|
||||
Not publicly visible on your profile page
|
||||
</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
)}
|
||||
</div>
|
||||
{!!feed.unread && (
|
||||
<div className="text-xs text-zinc-500 ml-2">
|
||||
{feed.unread}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</m.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</Collapsible>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user