@@ -124,3 +124,25 @@ export const sleep = (ms: number) =>
|
||||
|
||||
export const capitalizeFirstLetter = (string: string) =>
|
||||
string.charAt(0).toUpperCase() + string.slice(1)
|
||||
|
||||
export const pluralize = (
|
||||
noun: string,
|
||||
count: number,
|
||||
postfix: string | ((noun: string, rule: Intl.LDMLPluralRule) => string) = "s",
|
||||
) => {
|
||||
let rule: Intl.LDMLPluralRule
|
||||
// Check Support
|
||||
if (typeof Intl === "undefined" || !Intl.PluralRules) {
|
||||
if (count === 1) {
|
||||
rule = "one"
|
||||
} else {
|
||||
rule = "other"
|
||||
}
|
||||
}
|
||||
rule = new Intl.PluralRules("en", { type: "ordinal" }).select(count)
|
||||
|
||||
if (typeof postfix === "string") {
|
||||
return `${noun}${count === 1 ? "" : postfix}`
|
||||
}
|
||||
return postfix(noun, rule)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ListItemHoverOverlay } from "@renderer/components/ui/list-item-hover-ov
|
||||
import { useTitle } from "@renderer/hooks/common"
|
||||
import { views } from "@renderer/lib/constants"
|
||||
import { FeedViewType } from "@renderer/lib/enum"
|
||||
import { cn } from "@renderer/lib/utils"
|
||||
import { cn, pluralize } from "@renderer/lib/utils"
|
||||
import type { FeedModel } from "@renderer/models"
|
||||
import { ArticleItem } from "@renderer/modules/entry-column/article-item"
|
||||
import { NotificationItem } from "@renderer/modules/entry-column/notification-item"
|
||||
@@ -62,7 +62,6 @@ export function Component() {
|
||||
<>
|
||||
{feed.data?.feed && (
|
||||
<div className="mx-auto mt-12 flex max-w-5xl flex-col items-center justify-center p-4 lg:p-0">
|
||||
|
||||
<FeedIcon
|
||||
feed={feed.data.feed}
|
||||
className="mask-squircle mask shrink-0"
|
||||
@@ -79,11 +78,16 @@ export function Component() {
|
||||
<div className="mb-4 text-sm">
|
||||
<strong>{feed.data.subscriptionCount}</strong>
|
||||
{" "}
|
||||
follows with
|
||||
{pluralize("follow", feed.data.subscriptionCount)}
|
||||
{" "}
|
||||
with
|
||||
{" "}
|
||||
<strong>{feed.data.readCount}</strong>
|
||||
{" "}
|
||||
reads on
|
||||
{pluralize("read", feed.data.readCount)}
|
||||
{" "}
|
||||
on
|
||||
{" "}
|
||||
{APP_NAME}
|
||||
</div>
|
||||
<a className="mb-8" href={`${DEEPLINK_SCHEME}add?id=${id}`}>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { SessionProvider } from "@hono/auth-js/react"
|
||||
import { UserProvider } from "@renderer/providers/user-provider"
|
||||
import { Outlet } from "react-router-dom"
|
||||
|
||||
export function Component() {
|
||||
return (
|
||||
<SessionProvider>
|
||||
<>
|
||||
<UserProvider />
|
||||
<Outlet />
|
||||
</SessionProvider>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { signIn, useSession } from "@hono/auth-js/react"
|
||||
import { SessionProvider, signIn, useSession } from "@hono/auth-js/react"
|
||||
import { Logo } from "@renderer/components/icons/logo"
|
||||
import { Button } from "@renderer/components/ui/button"
|
||||
import { useSignOut } from "@renderer/hooks/biz/useSignOut"
|
||||
@@ -7,6 +7,13 @@ import { useEffect, useState } from "react"
|
||||
import { useLocation, useNavigate } from "react-router-dom"
|
||||
|
||||
export function Component() {
|
||||
return (
|
||||
<SessionProvider>
|
||||
<Login />
|
||||
</SessionProvider>
|
||||
)
|
||||
}
|
||||
function Login() {
|
||||
const { status } = useSession()
|
||||
const navigate = useNavigate()
|
||||
const [redirecting, setRedirecting] = useState(false)
|
||||
|
||||
Vendored
+4
@@ -4,7 +4,11 @@ declare module "@auth/core/types" {
|
||||
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
emailVerified: null
|
||||
image: string
|
||||
handle: null
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
interface Session {
|
||||
|
||||
Reference in New Issue
Block a user