mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 15:08:06 +08:00
migrate
This commit is contained in:
@ -6,6 +6,7 @@ import { NUM_INFINITE } from '@/app/components/billing/config'
|
||||
import { Plan } from '@/app/components/billing/type'
|
||||
import { IS_CLOUD_EDITION } from '@/config'
|
||||
import { isServer } from '@/utils/client'
|
||||
import { storage } from '@/utils/storage'
|
||||
|
||||
export type TriggerEventsLimitModalPayload = {
|
||||
usage: number
|
||||
@ -80,15 +81,10 @@ export const useTriggerEventsLimitModal = ({
|
||||
if (dismissedTriggerEventsLimitStorageKeysRef.current[storageKey])
|
||||
return
|
||||
|
||||
let persistDismiss = true
|
||||
const persistDismiss = storage.isAvailable()
|
||||
let hasDismissed = false
|
||||
try {
|
||||
if (localStorage.getItem(storageKey) === '1')
|
||||
hasDismissed = true
|
||||
}
|
||||
catch {
|
||||
persistDismiss = false
|
||||
}
|
||||
if (storage.get<string>(storageKey) === '1')
|
||||
hasDismissed = true
|
||||
if (hasDismissed)
|
||||
return
|
||||
|
||||
@ -110,16 +106,9 @@ export const useTriggerEventsLimitModal = ({
|
||||
const storageKey = showTriggerEventsLimitModal?.payload.storageKey
|
||||
if (!storageKey)
|
||||
return
|
||||
if (showTriggerEventsLimitModal?.payload.persistDismiss) {
|
||||
try {
|
||||
localStorage.setItem(storageKey, '1')
|
||||
return
|
||||
}
|
||||
catch {
|
||||
// ignore error and fall back to in-memory guard
|
||||
}
|
||||
}
|
||||
dismissedTriggerEventsLimitStorageKeysRef.current[storageKey] = true
|
||||
if (showTriggerEventsLimitModal?.payload.persistDismiss)
|
||||
storage.set(storageKey, '1')
|
||||
}, [showTriggerEventsLimitModal])
|
||||
|
||||
return {
|
||||
|
||||
@ -130,7 +130,7 @@ describe('ModalContextProvider trigger events limit modal', () => {
|
||||
expect(setItemSpy.mock.calls.length).toBeGreaterThan(0)
|
||||
})
|
||||
const [key, value] = setItemSpy.mock.calls[0]
|
||||
expect(key).toContain('trigger-events-limit-dismissed-workspace-1-professional-3000-')
|
||||
expect(key).toContain('v1:trigger-events-limit-dismissed-workspace-1-professional-3000-')
|
||||
expect(value).toBe('1')
|
||||
})
|
||||
|
||||
|
||||
@ -30,15 +30,15 @@ import {
|
||||
DEFAULT_ACCOUNT_SETTING_TAB,
|
||||
isValidAccountSettingTab,
|
||||
} from '@/app/components/header/account-setting/constants'
|
||||
import {
|
||||
EDUCATION_VERIFYING_LOCALSTORAGE_ITEM,
|
||||
} from '@/app/education-apply/constants'
|
||||
|
||||
import { STORAGE_KEYS } from '@/config/storage-keys'
|
||||
import { useAppContext } from '@/context/app-context'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
import {
|
||||
useAccountSettingModal,
|
||||
usePricingModal,
|
||||
} from '@/hooks/use-query-params'
|
||||
import { storage } from '@/utils/storage'
|
||||
|
||||
import {
|
||||
|
||||
@ -183,10 +183,10 @@ export const ModalContextProvider = ({
|
||||
|
||||
const [showAnnotationFullModal, setShowAnnotationFullModal] = useState(false)
|
||||
const handleCancelAccountSettingModal = () => {
|
||||
const educationVerifying = localStorage.getItem(EDUCATION_VERIFYING_LOCALSTORAGE_ITEM)
|
||||
const educationVerifying = storage.get<string>(STORAGE_KEYS.EDUCATION.VERIFYING)
|
||||
|
||||
if (educationVerifying === 'yes')
|
||||
localStorage.removeItem(EDUCATION_VERIFYING_LOCALSTORAGE_ITEM)
|
||||
storage.remove(STORAGE_KEYS.EDUCATION.VERIFYING)
|
||||
|
||||
accountSettingCallbacksRef.current?.onCancelCallback?.()
|
||||
accountSettingCallbacksRef.current = null
|
||||
|
||||
@ -19,6 +19,7 @@ import {
|
||||
ModelTypeEnum,
|
||||
} from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||
import { ZENDESK_FIELD_IDS } from '@/config'
|
||||
import { STORAGE_KEYS } from '@/config/storage-keys'
|
||||
import { fetchCurrentPlanInfo } from '@/service/billing'
|
||||
import {
|
||||
useModelListByType,
|
||||
@ -28,6 +29,7 @@ import {
|
||||
import {
|
||||
useEducationStatus,
|
||||
} from '@/service/use-education'
|
||||
import { storage } from '@/utils/storage'
|
||||
|
||||
export type ProviderContextState = {
|
||||
modelProviders: ModelProvider[]
|
||||
@ -200,7 +202,7 @@ export const ProviderContextProvider = ({
|
||||
|
||||
const { t } = useTranslation()
|
||||
useEffect(() => {
|
||||
if (localStorage.getItem('anthropic_quota_notice') === 'true')
|
||||
if (storage.get<string>(STORAGE_KEYS.UI.ANTHROPIC_QUOTA_NOTICE) === 'true')
|
||||
return
|
||||
|
||||
if (dayjs().isAfter(dayjs('2025-03-17')))
|
||||
@ -216,7 +218,7 @@ export const ProviderContextProvider = ({
|
||||
message: t('provider.anthropicHosted.trialQuotaTip', { ns: 'common' }),
|
||||
duration: 60000,
|
||||
onClose: () => {
|
||||
localStorage.setItem('anthropic_quota_notice', 'true')
|
||||
storage.set(STORAGE_KEYS.UI.ANTHROPIC_QUOTA_NOTICE, 'true')
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user