mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-14 06:25:35 +08:00
fix(rule): rule pages filter logic is not stable, fixes #313
This commit is contained in:
parent
bd597aa693
commit
1f22147cd1
@ -79,25 +79,36 @@ export default () => {
|
|||||||
|
|
||||||
let scrollElementRef: HTMLDivElement | undefined
|
let scrollElementRef: HTMLDivElement | undefined
|
||||||
|
|
||||||
|
const getRuleItemKey = ({ type, payload, proxy }: Rule) =>
|
||||||
|
`${type}-${payload}-${proxy}`
|
||||||
|
|
||||||
const ruleVirtualizer = createVirtualizer({
|
const ruleVirtualizer = createVirtualizer({
|
||||||
get count() {
|
get count() {
|
||||||
return filteredRules().length
|
return filteredRules().length
|
||||||
},
|
},
|
||||||
getItemKey: (index) => filteredRules()[index].payload,
|
getItemKey: (index) => getRuleItemKey(filteredRules()[index]),
|
||||||
getScrollElement: () => scrollElementRef!,
|
getScrollElement: () => scrollElementRef!,
|
||||||
estimateSize: () => 74,
|
estimateSize: () => 82,
|
||||||
overscan: 5,
|
overscan: 5,
|
||||||
})
|
})
|
||||||
|
|
||||||
const ruleVirtualizerItems = ruleVirtualizer.getVirtualItems()
|
const ruleVirtualizerItems = ruleVirtualizer.getVirtualItems()
|
||||||
|
|
||||||
|
const getRuleProviderItemKey = ({
|
||||||
|
type,
|
||||||
|
name,
|
||||||
|
vehicleType,
|
||||||
|
behavior,
|
||||||
|
}: RuleProvider) => `${type}-${name}-${vehicleType}-${behavior}`
|
||||||
|
|
||||||
const ruleProviderVirtualizer = createVirtualizer({
|
const ruleProviderVirtualizer = createVirtualizer({
|
||||||
get count() {
|
get count() {
|
||||||
return filteredRuleProviders().length
|
return filteredRuleProviders().length
|
||||||
},
|
},
|
||||||
getItemKey: (index) => filteredRuleProviders()[index].name,
|
getItemKey: (index) =>
|
||||||
|
getRuleProviderItemKey(filteredRuleProviders()[index]),
|
||||||
getScrollElement: () => scrollElementRef!,
|
getScrollElement: () => scrollElementRef!,
|
||||||
estimateSize: () => 74,
|
estimateSize: () => 82,
|
||||||
overscan: 5,
|
overscan: 5,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -157,7 +168,7 @@ export default () => {
|
|||||||
>
|
>
|
||||||
{ruleVirtualizerItems.map((virtualizerItem) => {
|
{ruleVirtualizerItems.map((virtualizerItem) => {
|
||||||
const rule = filteredRules().find(
|
const rule = filteredRules().find(
|
||||||
(rule) => rule.payload === virtualizerItem.key,
|
(rule) => getRuleItemKey(rule) === virtualizerItem.key,
|
||||||
)!
|
)!
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -197,7 +208,8 @@ export default () => {
|
|||||||
>
|
>
|
||||||
{ruleProviderVirtualizerItems.map((virtualizerItem) => {
|
{ruleProviderVirtualizerItems.map((virtualizerItem) => {
|
||||||
const ruleProvider = ruleProviders().find(
|
const ruleProvider = ruleProviders().find(
|
||||||
(ruleProvider) => ruleProvider.name === virtualizerItem.key,
|
(ruleProvider) =>
|
||||||
|
getRuleProviderItemKey(ruleProvider) === virtualizerItem.key,
|
||||||
)!
|
)!
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user