refactor & perf: import { noop } from 'lodash-es' across web (#17439)

This commit is contained in:
yusheng chen
2025-04-06 17:56:08 +08:00
committed by GitHub
parent 7016ccef10
commit c05e03fc09
87 changed files with 271 additions and 184 deletions

View File

@@ -14,6 +14,7 @@ import { useSelector as useAppContextSelector } from '@/context/app-context'
import type { FilterState } from './filter-management'
import { useTranslation } from 'react-i18next'
import { useTabSearchParams } from '@/hooks/use-tab-searchparams'
import { noop } from 'lodash-es'
export type PluginPageContextValue = {
containerRef: React.RefObject<HTMLDivElement>
@@ -29,15 +30,15 @@ export type PluginPageContextValue = {
export const PluginPageContext = createContext<PluginPageContextValue>({
containerRef: { current: null },
currentPluginID: undefined,
setCurrentPluginID: () => { },
setCurrentPluginID: noop,
filters: {
categories: [],
tags: [],
searchQuery: '',
},
setFilters: () => { },
setFilters: noop,
activeTab: '',
setActiveTab: () => { },
setActiveTab: noop,
options: [],
})

View File

@@ -11,6 +11,7 @@ import Line from '../../marketplace/empty/line'
import { useInstalledPluginList } from '@/service/use-plugins'
import { useTranslation } from 'react-i18next'
import { SUPPORT_INSTALL_LOCAL_FILE_EXTENSIONS } from '@/config'
import { noop } from 'lodash-es'
const Empty = () => {
const { t } = useTranslation()
@@ -99,14 +100,14 @@ const Empty = () => {
</div>
</div>
{selectedAction === 'github' && <InstallFromGitHub
onSuccess={() => { }}
onSuccess={noop}
onClose={() => setSelectedAction(null)}
/>}
{selectedAction === 'local' && selectedFile
&& (<InstallFromLocalPackage
file={selectedFile}
onClose={() => setSelectedAction(null)}
onSuccess={() => { }}
onSuccess={noop}
/>
)
}

View File

@@ -39,6 +39,7 @@ import { marketplaceApiPrefix } from '@/config'
import { SUPPORT_INSTALL_LOCAL_FILE_EXTENSIONS } from '@/config'
import { LanguagesSupported } from '@/i18n/language'
import I18n from '@/context/i18n'
import { noop } from 'lodash-es'
const PACKAGE_IDS_KEY = 'package-ids'
const BUNDLE_INFO_KEY = 'bundle-info'
@@ -230,8 +231,8 @@ const PluginPage = ({
{currentFile && (
<InstallFromLocalPackage
file={currentFile}
onClose={removeFile ?? (() => { })}
onSuccess={() => { }}
onClose={removeFile ?? noop}
onSuccess={noop}
/>
)}
<input
@@ -240,7 +241,7 @@ const PluginPage = ({
type="file"
id="fileUploader"
accept={SUPPORT_INSTALL_LOCAL_FILE_EXTENSIONS}
onChange={fileChangeHandle ?? (() => { })}
onChange={fileChangeHandle ?? noop}
/>
</>
)}

View File

@@ -17,6 +17,7 @@ import {
import { useSelector as useAppContextSelector } from '@/context/app-context'
import { useTranslation } from 'react-i18next'
import { SUPPORT_INSTALL_LOCAL_FILE_EXTENSIONS } from '@/config'
import { noop } from 'lodash-es'
type Props = {
onSwitchToMarketplaceTab: () => void
@@ -118,14 +119,14 @@ const InstallPluginDropdown = ({
</PortalToFollowElemContent>
</div>
{selectedAction === 'github' && <InstallFromGitHub
onSuccess={() => { }}
onSuccess={noop}
onClose={() => setSelectedAction(null)}
/>}
{selectedAction === 'local' && selectedFile
&& (<InstallFromLocalPackage
file={selectedFile}
onClose={() => setSelectedAction(null)}
onSuccess={() => { }}
onSuccess={noop}
/>
)
}