mirror of
https://github.com/langgenius/dify.git
synced 2026-06-03 08:16:37 +08:00
refactor(web): migrate question classifier label hint storage (#36932)
Co-authored-by: lmlm <7487674+popsiclelmlm@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -4397,11 +4397,6 @@
|
|||||||
"count": 9
|
"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": {
|
"web/app/components/workflow/nodes/question-classifier/use-single-run-form-params.ts": {
|
||||||
"ts/no-explicit-any": {
|
"ts/no-explicit-any": {
|
||||||
"count": 8
|
"count": 8
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { ReactSortable } from 'react-sortablejs'
|
import { ReactSortable } from 'react-sortablejs'
|
||||||
import { ArrowDownRoundFill } from '@/app/components/base/icons/src/vender/solid/general'
|
import { ArrowDownRoundFill } from '@/app/components/base/icons/src/vender/solid/general'
|
||||||
|
import { useLocalStorage } from '@/hooks/use-local-storage'
|
||||||
import { useEdgesInteractions } from '../../../hooks'
|
import { useEdgesInteractions } from '../../../hooks'
|
||||||
import AddButton from '../../_base/components/add-button'
|
import AddButton from '../../_base/components/add-button'
|
||||||
import Item from './class-item'
|
import Item from './class-item'
|
||||||
@@ -42,17 +43,8 @@ const ClassList: FC<Props> = ({
|
|||||||
const [shouldScrollToEnd, setShouldScrollToEnd] = useState(false)
|
const [shouldScrollToEnd, setShouldScrollToEnd] = useState(false)
|
||||||
const prevListLength = useRef(list.length)
|
const prevListLength = useRef(list.length)
|
||||||
const [collapsed, setCollapsed] = useState(false)
|
const [collapsed, setCollapsed] = useState(false)
|
||||||
const [isRenameHintDismissed, setIsRenameHintDismissed] = useState(() => {
|
const [storedRenameHintDismissed, setIsRenameHintDismissed] = useLocalStorage<boolean>(INLINE_LABEL_HINT_STORAGE_KEY)
|
||||||
if (typeof window === 'undefined')
|
const isRenameHintDismissed = storedRenameHintDismissed ?? false
|
||||||
return true
|
|
||||||
|
|
||||||
try {
|
|
||||||
return window.localStorage.getItem(INLINE_LABEL_HINT_STORAGE_KEY) === 'true'
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const handleClassChange = useCallback((index: number) => {
|
const handleClassChange = useCallback((index: number) => {
|
||||||
return (value: Topic) => {
|
return (value: Topic) => {
|
||||||
@@ -104,12 +96,7 @@ const ClassList: FC<Props> = ({
|
|||||||
return
|
return
|
||||||
|
|
||||||
setIsRenameHintDismissed(true)
|
setIsRenameHintDismissed(true)
|
||||||
try {
|
}, [isRenameHintDismissed, setIsRenameHintDismissed])
|
||||||
window.localStorage.setItem(INLINE_LABEL_HINT_STORAGE_KEY, 'true')
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
}
|
|
||||||
}, [isRenameHintDismissed])
|
|
||||||
|
|
||||||
const shouldShowRenameHint = !readonly && !isRenameHintDismissed && list.some((item, index) => {
|
const shouldShowRenameHint = !readonly && !isRenameHintDismissed && list.some((item, index) => {
|
||||||
return isDefaultClassLabel(item.label, index + 1, t)
|
return isDefaultClassLabel(item.label, index + 1, t)
|
||||||
|
|||||||
Reference in New Issue
Block a user