feat: feed claim indicator

This commit is contained in:
DIYgod 2024-09-12 21:28:54 +08:00
parent 9e770c96a1
commit 85d8e226fb
No known key found for this signature in database
7 changed files with 5659 additions and 3673 deletions

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"><path fill="#fff" fill-opacity=".01" d="M24 0v24H0V0z"/><path fill="#10161F" fill-rule="evenodd" d="M9.843 2.27a3.05 3.05 0 0 1 4.314 0l1.046 1.047a.95.95 0 0 0 .672.278h1.479a3.05 3.05 0 0 1 3.05 3.05v1.48c0 .251.1.493.279.67l1.046 1.047a3.05 3.05 0 0 1 0 4.314l-1.046 1.046a.95.95 0 0 0-.279.672v1.479a3.05 3.05 0 0 1-3.05 3.05h-1.48a.95.95 0 0 0-.67.279l-1.047 1.046a3.05 3.05 0 0 1-4.314 0l-1.046-1.046a.95.95 0 0 0-.671-.278h-1.48a3.05 3.05 0 0 1-3.05-3.051v-1.48a.95.95 0 0 0-.279-.67l-1.046-1.047a3.05 3.05 0 0 1 0-4.314l1.046-1.046a.95.95 0 0 0 .279-.671v-1.48a3.05 3.05 0 0 1 3.05-3.05h1.48a.95.95 0 0 0 .67-.278zm5.4 6.52a1.05 1.05 0 1 1 1.087 1.798c-1.98 1.196-3.448 2.617-4.586 4.58a1.05 1.05 0 0 1-1.746.108 11.643 11.643 0 0 0-2.273-2.273 1.05 1.05 0 1 1 1.27-1.674c.628.476 1.2.99 1.728 1.551 1.209-1.683 2.696-2.988 4.52-4.09" clip-rule="evenodd"/></svg>

After

Width:  |  Height:  |  Size: 945 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"><path fill="#fff" fill-opacity=".01" d="M24 0v24H0V0z"/><path stroke="#10161F" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.786 9.69c-2.113 1.276-3.715 2.82-4.951 4.951a12.695 12.695 0 0 0-2.475-2.475m-1.714-7.52h1.48a2 2 0 0 0 1.413-.586l1.046-1.046a2 2 0 0 1 2.829 0L14.46 4.06a2 2 0 0 0 1.414.586h1.48a2 2 0 0 1 2 2v1.48a2 2 0 0 0 .585 1.413l1.046 1.046a2 2 0 0 1 0 2.829L19.94 14.46a2 2 0 0 0-.585 1.414v1.48a2 2 0 0 1-2 2h-1.48a2 2 0 0 0-1.414.585l-1.046 1.046a2 2 0 0 1-2.829 0L9.54 19.94a2 2 0 0 0-1.414-.585h-1.48a2 2 0 0 1-2-2v-1.48a2 2 0 0 0-.585-1.414l-1.046-1.046a2 2 0 0 1 0-2.829L4.06 9.54a2 2 0 0 0 .586-1.414v-1.48a2 2 0 0 1 2-2"/></svg>

After

Width:  |  Height:  |  Size: 754 B

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@ const TooltipContent = React.forwardRef<
}}
>
{/* https://github.com/radix-ui/primitives/discussions/868 */}
<TooltipPrimitive.Arrow className="z-50 fill-white drop-shadow-[0_0_1px_theme(colors.accent.DEFAULT/0.3)] [clip-path:inset(0_-10px_-10px_-10px)] dark:fill-neutral-950 dark:drop-shadow-[0_0_1px_theme(colors.white/0.5)]" />
<TooltipPrimitive.Arrow className="z-50 fill-white [clip-path:inset(0_-10px_-10px_-10px)] dark:fill-neutral-950 dark:drop-shadow-[0_0_1px_theme(colors.white/0.5)]" />
{props.children}
</m.div>
</TooltipPrimitive.Content>

View File

@ -17,7 +17,9 @@ export type ActiveList = {
export type FeedResponse = SubscriptionResponse[number]["feeds"]
export type FeedModel = ExtractBizResponse<typeof apiClient.feeds.$get>["data"]["feed"]
export type FeedModel = ExtractBizResponse<typeof apiClient.feeds.$get>["data"]["feed"] & {
owner?: UserModel | null
}
export type SubscriptionResponse = Array<
ExtractBizResponse<typeof apiClient.subscriptions.$get>["data"][number] & {

View File

@ -2,6 +2,7 @@ import { getMainContainerElement } from "@renderer/atoms/dom"
import { useWhoami } from "@renderer/atoms/user"
import { FeedIcon } from "@renderer/components/feed-icon"
import { OouiUserAnonymous } from "@renderer/components/icons/OouiUserAnonymous"
import { Avatar, AvatarFallback, AvatarImage } from "@renderer/components/ui/avatar"
import {
Tooltip,
TooltipContent,
@ -22,6 +23,7 @@ import { WEB_URL } from "@shared/constants"
import dayjs from "dayjs"
import { memo, useCallback } from "react"
import { usePresentUserProfileModal } from "../profile/hooks"
import { UnreadNumber } from "./unread-number"
interface FeedItemProps {
@ -58,7 +60,7 @@ const FeedItemImpl = ({ view, feedId, className, showUnreadCount = true }: FeedI
const { items } = useFeedActions({ feedId, view })
const me = useWhoami()
const isOwned = feed && feed.ownerUserId === me?.id
const presentUserProfile = usePresentUserProfileModal("drawer")
if (!feed) return null
@ -118,17 +120,56 @@ const FeedItemImpl = ({ view, feedId, className, showUnreadCount = true }: FeedI
>
{getPreferredTitle(feed)}
</div>
{isOwned && (
<Tooltip delayDuration={300}>
<TooltipTrigger asChild>
<i className="i-mgc-flag-1-cute-fi ml-1 shrink-0 text-base text-accent" />
</TooltipTrigger>
{feed.ownerUserId &&
(feed.ownerUserId === me?.id ? (
<Tooltip delayDuration={300}>
<TooltipTrigger asChild>
<i className="i-mgc-certificate-cute-fi ml-1.5 shrink-0 text-[15px] text-accent" />
</TooltipTrigger>
<TooltipPortal>
<TooltipContent>This feed is owned by you</TooltipContent>
</TooltipPortal>
</Tooltip>
)}
<TooltipPortal>
<TooltipContent className="px-4 py-2">
<div className="flex items-center text-base font-semibold">
<i className="i-mgc-certificate-cute-fi mr-2 shrink-0 text-accent" />
Claimed feed
</div>
<div>This feed is claimed by you.</div>
</TooltipContent>
</TooltipPortal>
</Tooltip>
) : (
<Tooltip delayDuration={300}>
<TooltipTrigger asChild>
<i className="i-mgc-certificate-cute-fi ml-1.5 shrink-0 text-[15px] text-amber-500" />
</TooltipTrigger>
<TooltipPortal>
<TooltipContent className="px-4 py-2">
<div className="flex items-center text-base font-semibold">
<i className="i-mgc-certificate-cute-fi mr-2 shrink-0 text-amber-500" />
Claimed feed
</div>
<div className="mt-1 flex items-center gap-1.5">
<span>This feed is claimed by</span>
{feed.owner ? (
<Avatar
className="inline-flex aspect-square size-5 rounded-full"
onClick={(e) => {
e.stopPropagation()
presentUserProfile(feed.owner!.id)
}}
>
<AvatarImage src={feed.owner.image || undefined} />
<AvatarFallback>{feed.owner.name?.slice(0, 2)}</AvatarFallback>
</Avatar>
) : (
<span>its owner.</span>
)}
</div>
</TooltipContent>
</TooltipPortal>
</Tooltip>
))}
{feed.errorAt && (
<Tooltip delayDuration={300}>
<TooltipTrigger asChild>

View File

@ -32,6 +32,9 @@ class FeedActions {
feed.errorAt = null
}
if (feed.id) {
// Not all API return the owner, so merging is needed here.
feed.owner = feed.owner || state.feeds[feed.id]?.owner
state.feeds[feed.id] = feed
} else {
// Store temp feed in memory