fix: trial limit
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
export const MAX_SUBSCRIPTION_COUNT = 500
|
||||
export const MAX_INBOX_COUNT = 3
|
||||
|
||||
export const MAX_TRIAL_USER_FEED_SUBSCRIPTION = 5
|
||||
export const MAX_TRIAL_USER_LIST_SUBSCRIPTION = 5
|
||||
export const MAX_TRIAL_USER_INBOX_SUBSCRIPTION = 1
|
||||
@@ -3,9 +3,9 @@ import { t } from "i18next"
|
||||
import { useCallback } from "react"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { useServerConfigs } from "~/atoms/server-configs"
|
||||
import { useUserRole } from "~/atoms/user"
|
||||
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
|
||||
import { MAX_TRIAL_USER_FEED_SUBSCRIPTION } from "~/constants/limit"
|
||||
import { CustomSafeError } from "~/errors/CustomSafeError"
|
||||
import { useActivationModal } from "~/modules/activation"
|
||||
import type { FeedFormDataValuesType } from "~/modules/discover/feed-form"
|
||||
@@ -23,11 +23,14 @@ const useCanFollowMoreInboxAndNotify = () => {
|
||||
const listCurrentCount = useListSubscriptionCount()
|
||||
const feedCurrentCount = useFeedSubscriptionCount()
|
||||
const presentActivationModal = useActivationModal()
|
||||
const serverConfigs = useServerConfigs()
|
||||
|
||||
return useEventCallback((type: "list" | "feed") => {
|
||||
if (role === UserRole.Trial) {
|
||||
const LIMIT =
|
||||
type !== "list" ? MAX_TRIAL_USER_FEED_SUBSCRIPTION : MAX_TRIAL_USER_FEED_SUBSCRIPTION
|
||||
(type !== "list"
|
||||
? serverConfigs?.MAX_TRIAL_USER_FEED_SUBSCRIPTION
|
||||
: serverConfigs?.MAX_TRIAL_USER_LIST_SUBSCRIPTION) || 50
|
||||
const CURRENT = type === "list" ? listCurrentCount : feedCurrentCount
|
||||
const can = CURRENT < LIMIT
|
||||
if (!can) {
|
||||
|
||||
@@ -19,31 +19,26 @@ import { useEventCallback } from "usehooks-ts"
|
||||
import { useUserRole } from "~/atoms/user"
|
||||
import { CopyButton } from "~/components/ui/code-highlighter"
|
||||
import { useCurrentModal, useModalStack } from "~/components/ui/modal/stacked/hooks"
|
||||
import { MAX_TRIAL_USER_INBOX_SUBSCRIPTION } from "~/constants/limit"
|
||||
import { CustomSafeError } from "~/errors/CustomSafeError"
|
||||
import { createErrorToaster } from "~/lib/error-parser"
|
||||
import { useInboxList } from "~/queries/inboxes"
|
||||
import { inboxActions, useInboxById } from "~/store/inbox"
|
||||
import { subscriptionActions, useInboxSubscriptionCount } from "~/store/subscription"
|
||||
import { subscriptionActions } from "~/store/subscription"
|
||||
|
||||
import { useActivationModal } from "../activation"
|
||||
import { InboxForm } from "./inbox-form"
|
||||
|
||||
const useCanCreateMoreInboxAndNotify = () => {
|
||||
const role = useUserRole()
|
||||
const currentInboxCount = useInboxSubscriptionCount()
|
||||
const presentActivationModal = useActivationModal()
|
||||
|
||||
return useEventCallback(() => {
|
||||
if (role === UserRole.Trial) {
|
||||
const can = currentInboxCount < MAX_TRIAL_USER_INBOX_SUBSCRIPTION
|
||||
const can = false
|
||||
if (!can) {
|
||||
presentActivationModal()
|
||||
|
||||
throw new CustomSafeError(
|
||||
`Trial user cannot create more inboxes, limit: ${MAX_TRIAL_USER_INBOX_SUBSCRIPTION}, current: ${currentInboxCount}`,
|
||||
true,
|
||||
)
|
||||
throw new CustomSafeError(`Trial user cannot create more inboxes`, true)
|
||||
}
|
||||
return can
|
||||
} else {
|
||||
|
||||
@@ -5081,6 +5081,8 @@ declare const _routes: hono_hono_base.HonoBase<Env, {
|
||||
IS_RSS3_TESTNET: boolean;
|
||||
PRODUCT_HUNT_VOTE_URL: string;
|
||||
ANNOUNCEMENT: string;
|
||||
MAX_TRIAL_USER_FEED_SUBSCRIPTION: number;
|
||||
MAX_TRIAL_USER_LIST_SUBSCRIPTION: number;
|
||||
};
|
||||
};
|
||||
outputFormat: "json" | "text";
|
||||
|
||||
Reference in New Issue
Block a user