Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(web): migrate question classifier label hint storage (#36932)

lmlmb682591c7a73
diff --git a/eslint-suppressions.json b/eslint-suppressions.json
index 3d4323a0963..100e36e2f06 100644
--- a/eslint-suppressions.json
+++ b/eslint-suppressions.json
@@ -4397,11 +4397,6 @@
"count": 9
}
},
- "web/app/components/workflow/nodes/question-classifier/components/class-list.tsx": {
- "no-restricted-properties": {
- "count": 2
- }
- },
"web/app/components/workflow/nodes/question-classifier/use-single-run-form-params.ts": {
"ts/no-explicit-any": {
"count": 8
diff --git a/web/app/components/workflow/nodes/question-classifier/components/class-list.tsx b/web/app/components/workflow/nodes/question-classifier/components/class-list.tsx
index bb6341ae5f3..ef7764a106c 100644
--- a/web/app/components/workflow/nodes/question-classifier/components/class-list.tsx
+++ b/web/app/components/workflow/nodes/question-classifier/components/class-list.tsx
@@ -11,6 +11,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { ReactSortable } from 'react-sortablejs'
import { ArrowDownRoundFill } from '@/app/components/base/icons/src/vender/solid/general'
+import { useLocalStorage } from '@/hooks/use-local-storage'
import { useEdgesInteractions } from '../../../hooks'
import AddButton from '../../_base/components/add-button'
import Item from './class-item'
@@ -42,17 +43,8 @@ const ClassList: FC<Props> = ({
const [shouldScrollToEnd, setShouldScrollToEnd] = useState(false)
const prevListLength = useRef(list.length)
const [collapsed, setCollapsed] = useState(false)
- const [isRenameHintDismissed, setIsRenameHintDismissed] = useState(() => {
- if (typeof window === 'undefined')
- return true
-
- try {
- return window.localStorage.getItem(INLINE_LABEL_HINT_STORAGE_KEY) === 'true'
- }
- catch {
- return false
- }
- })
+ const [storedRenameHintDismissed, setIsRenameHintDismissed] = useLocalStorage<boolean>(INLINE_LABEL_HINT_STORAGE_KEY)
+ const isRenameHintDismissed = storedRenameHintDismissed ?? false
const handleClassChange = useCallback((index: number) => {
return (value: Topic) => {
@@ -104,12 +96,7 @@ const ClassList: FC<Props> = ({
return
setIsRenameHintDismissed(true)
- try {
- window.localStorage.setItem(INLINE_LABEL_HINT_STORAGE_KEY, 'true')
- }
- catch {
- }
- }, [isRenameHintDismissed])
+ }, [isRenameHintDismissed, setIsRenameHintDismissed])
const shouldShowRenameHint = !readonly && !isRenameHintDismissed && list.some((item, index) => {
return isDefaultClassLabel(item.label, index + 1, t)