refactor(web): migrate workflow featured collapsed storage (#36918)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Myshkin451 2026-06-02 11:40:59 +08:00 committed by GitHub
parent f465dc5090
commit 2257a4f1ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 36 deletions

View File

@ -3413,16 +3413,6 @@
"count": 1
}
},
"web/app/components/workflow/block-selector/featured-tools.tsx": {
"no-restricted-properties": {
"count": 2
}
},
"web/app/components/workflow/block-selector/featured-triggers.tsx": {
"no-restricted-properties": {
"count": 2
}
},
"web/app/components/workflow/block-selector/hooks.ts": {
"react/set-state-in-effect": {
"count": 1

View File

@ -13,8 +13,8 @@ import Loading from '@/app/components/base/loading'
import InstallFromMarketplace from '@/app/components/plugins/install-plugin/install-from-marketplace'
import Action from '@/app/components/workflow/block-selector/market-place-plugin/action'
import { useGetLanguage } from '@/context/i18n'
import { useLocalStorage } from '@/hooks/use-local-storage'
import Link from '@/next/link'
import { isServer } from '@/utils/client'
import { formatNumber } from '@/utils/format'
import { getMarketplaceUrl } from '@/utils/var'
import BlockIcon from '../block-icon'
@ -55,18 +55,7 @@ const FeaturedTools = ({
const previewCardHandle = useMemo(() => createPreviewCardHandle<FeaturedToolPreviewPayload>(), [])
const [visibleCount, setVisibleCount] = useState(INITIAL_VISIBLE_COUNT)
const [visibleCountPlugins, setVisibleCountPlugins] = useState(plugins)
const [isCollapsed, setIsCollapsed] = useState<boolean>(() => {
if (isServer)
return false
const stored = window.localStorage.getItem(STORAGE_KEY)
return stored === 'true'
})
useEffect(() => {
if (isServer)
return
window.localStorage.setItem(STORAGE_KEY, String(isCollapsed))
}, [isCollapsed])
const [isCollapsed, setIsCollapsed] = useLocalStorage<boolean>(STORAGE_KEY, false)
if (visibleCountPlugins !== plugins) {
setVisibleCountPlugins(plugins)

View File

@ -13,8 +13,8 @@ import Loading from '@/app/components/base/loading'
import InstallFromMarketplace from '@/app/components/plugins/install-plugin/install-from-marketplace'
import Action from '@/app/components/workflow/block-selector/market-place-plugin/action'
import { useGetLanguage } from '@/context/i18n'
import { useLocalStorage } from '@/hooks/use-local-storage'
import Link from '@/next/link'
import { isServer } from '@/utils/client'
import { formatNumber } from '@/utils/format'
import { getMarketplaceUrl } from '@/utils/var'
import BlockIcon from '../block-icon'
@ -53,18 +53,7 @@ const FeaturedTriggers = ({
const triggerActionPreviewCardHandle = useMemo(() => createPreviewCardHandle<TriggerPluginActionPreviewPayload>(), [])
const [visibleCount, setVisibleCount] = useState(INITIAL_VISIBLE_COUNT)
const [visibleCountPlugins, setVisibleCountPlugins] = useState(plugins)
const [isCollapsed, setIsCollapsed] = useState<boolean>(() => {
if (isServer)
return false
const stored = window.localStorage.getItem(STORAGE_KEY)
return stored === 'true'
})
useEffect(() => {
if (isServer)
return
window.localStorage.setItem(STORAGE_KEY, String(isCollapsed))
}, [isCollapsed])
const [isCollapsed, setIsCollapsed] = useLocalStorage<boolean>(STORAGE_KEY, false)
if (visibleCountPlugins !== plugins) {
setVisibleCountPlugins(plugins)