feat(desktop): use analytics field

This commit is contained in:
DIYgod
2025-05-05 20:57:18 +08:00
parent 7500ad2f05
commit 9873e9af0f
5 changed files with 43 additions and 15 deletions
@@ -41,7 +41,7 @@ export const FeedCard: FC<{
onSuccess,
children,
followButtonVariant,
followedButtonVariant,
followedButtonVariant = "ghost",
followButtonClassName,
followedButtonClassName,
className,
@@ -92,25 +92,29 @@ export const FeedCard: FC<{
)}
<CardFooter className="flex justify-between gap-4 px-4 pb-3">
<div className="flex items-center gap-3 text-sm text-zinc-500 dark:text-zinc-400">
<div className="flex items-center gap-1.5">
<i className="i-mgc-user-3-cute-re" />
{item.analytics?.subscriptionCount && (
<div className="flex items-center gap-1.5">
<i className="i-mgc-user-3-cute-re" />
<span>
{numberFormatter.format(item.subscriptionCount ?? 0)}{" "}
{t("feed.follower", { count: item.subscriptionCount ?? 0 })}
</span>
</div>
{item.updatesPerWeek ? (
<span>
{numberFormatter.format(item.analytics.subscriptionCount)}{" "}
{t("feed.follower", { count: item.analytics.subscriptionCount })}
</span>
</div>
)}
{item.analytics?.updatesPerWeek ? (
<div className="flex items-center gap-1.5">
<i className="i-mgc-safety-certificate-cute-re" />
<span>{t("feed.entry_week", { count: item.updatesPerWeek ?? 0 })}</span>
<span>
{t("feed.entry_week", { count: item.analytics.updatesPerWeek ?? 0 })}
</span>
</div>
) : item.entries?.[0]?.publishedAt ? (
) : item.analytics?.latestEntryPublishedAt ? (
<div className="flex items-center gap-1.5">
<i className="i-mgc-safe-alert-cute-re" />
<span>{t("feed.updated_at")}</span>
<RelativeTime
date={item.entries[0].publishedAt}
date={item.analytics.latestEntryPublishedAt}
displayAbsoluteTimeAfterDay={Infinity}
/>
</div>
@@ -140,7 +144,7 @@ export const FeedCard: FC<{
onClick={() => {
follow({
isList: !!item.list?.id,
id: item.list?.id,
id: item.list?.id || item.feed?.id,
url: item.feed?.url,
defaultValues: {
view: getRouteParams().view.toString(),
@@ -322,6 +322,7 @@ export function DiscoverForm({ type = "search" }: { type?: string }) {
item={item}
onSuccess={handleSuccess}
onUnSubscribed={handleUnSubscribed}
className="last:border-b-0"
/>
))}
</div>
@@ -135,7 +135,7 @@ export function Trending({
followButtonVariant="ghost"
followedButtonClassName="px-3 -mr-3"
followButtonClassName="border-accent text-accent px-3 -mr-3"
className="pl-2"
className="pl-2 [&:nth-last-child(-n+2)]:border-b-0"
>
<div
className={cn(
+4
View File
@@ -34,6 +34,10 @@ export type TransactionModel = ExtractBizResponse<
export type FeedModel = ExtractBizResponse<typeof _apiClient.feeds.$get>["data"]["feed"]
export type FeedAnalyticsModel = ExtractBizResponse<
typeof _apiClient.feeds.$get
>["data"]["analytics"]
export type ListModel = Omit<ListModelPoplutedFeeds, "feeds">
export type ListModelPoplutedFeeds = ExtractBizResponse<
typeof _apiClient.lists.$get
+20 -1
View File
@@ -13915,6 +13915,13 @@ declare const _routes: hono_hono_base.HonoBase<Env, ({
} | null | undefined;
} | undefined;
docs?: string | undefined;
analytics?: {
view: number | null;
feedId: string;
updatesPerWeek: number | null;
subscriptionCount: number | null;
latestEntryPublishedAt: string | null;
} | undefined;
}[];
};
outputFormat: "json";
@@ -14682,6 +14689,12 @@ declare const _routes: hono_hono_base.HonoBase<Env, ({
}[] | null | undefined;
};
readCount: number;
analytics?: {
view: number | null;
updatesPerWeek: number | null;
subscriptionCount: number | null;
latestEntryPublishedAt: string | null;
} | undefined;
subscription?: {
createdAt: string;
userId: string;
@@ -16580,7 +16593,6 @@ declare const _routes: hono_hono_base.HonoBase<Env, ({
data: {
view: number | null;
feedId: string;
subscriptionCount: number;
feed: {
id: string;
type: "feed";
@@ -16613,6 +16625,13 @@ declare const _routes: hono_hono_base.HonoBase<Env, ({
suspended: boolean | null;
}[] | null | undefined;
} | null;
analytics: {
view: number | null;
feedId: string;
updatesPerWeek: number | null;
subscriptionCount: number | null;
latestEntryPublishedAt: string | null;
} | null;
}[];
};
outputFormat: "json";