From 57a24136e8d4623d422e08f8b7e264260bcaa8fa Mon Sep 17 00:00:00 2001 From: thiendekaco Date: Wed, 15 Jan 2025 14:12:39 +0700 Subject: [PATCH 1/2] [issue-278] Mythical_Telegram_App - Error not showing card with Power > 110 when filtering --- .../src/Popup/Home/Cards/ToolFiters/ToolFiltersModal.tsx | 5 +++-- .../extension-koni-ui/src/constants/myth/optionFilterCard.ts | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/extension-koni-ui/src/Popup/Home/Cards/ToolFiters/ToolFiltersModal.tsx b/packages/extension-koni-ui/src/Popup/Home/Cards/ToolFiters/ToolFiltersModal.tsx index a482116bf4..277c6414f6 100644 --- a/packages/extension-koni-ui/src/Popup/Home/Cards/ToolFiters/ToolFiltersModal.tsx +++ b/packages/extension-koni-ui/src/Popup/Home/Cards/ToolFiters/ToolFiltersModal.tsx @@ -3,6 +3,7 @@ import { MythButton } from '@subwallet/extension-koni-ui/components/Mythical'; import { NFLRivalCard } from '@subwallet/extension-koni-ui/connector/booka/types'; +import { MaxLevelIdx, MaxPowerIdx } from '@subwallet/extension-koni-ui/constants'; import { ConditionProcessState } from '@subwallet/extension-koni-ui/Popup/Home/Cards'; import { FilterItems, FilterOption } from '@subwallet/extension-koni-ui/Popup/Home/Cards/ToolFiters/index'; import { ThemeProps } from '@subwallet/extension-koni-ui/types'; @@ -99,13 +100,13 @@ const Component = ({ className, filterItems, handleCancel, handleReset, onConfir let isCardLevelPassed = tmpItemsSelected[FilterOption.LEVEL_OPTION].length === 0; if (!isCardPowerPassed) { - const idx = Math.floor((card.power - 50 >= 0 ? card.power - 50 : 0) / 10); + const idx = Math.min(Math.floor((card.power - 50 >= 0 ? card.power - 50 : 0) / 10), MaxPowerIdx); isCardPowerPassed = tmpItemsSelected[FilterOption.POWER_OPTION].includes(idx.toString()); } if (!isCardLevelPassed) { - const idx = Math.floor(card.level / 5); + const idx = Math.min(Math.floor(card.level / 5), MaxLevelIdx); isCardLevelPassed = tmpItemsSelected[FilterOption.LEVEL_OPTION].includes(idx.toString()); } diff --git a/packages/extension-koni-ui/src/constants/myth/optionFilterCard.ts b/packages/extension-koni-ui/src/constants/myth/optionFilterCard.ts index dfd22f74f1..370fbc0415 100644 --- a/packages/extension-koni-ui/src/constants/myth/optionFilterCard.ts +++ b/packages/extension-koni-ui/src/constants/myth/optionFilterCard.ts @@ -98,6 +98,7 @@ export const RarityOptions = [ { id: 'mythical', label: 'Mythical' } ]; +export const MaxPowerIdx = 5; export const PowerOptions = [ { id: '0', label: '<60' }, { id: '1', label: '60-69' }, @@ -107,6 +108,7 @@ export const PowerOptions = [ { id: '5', label: '100+' } ]; +export const MaxLevelIdx = 4; export const LevelOptions = [ { id: '0', label: '≥1' }, { id: '1', label: '≥5' }, From 7ff2e82c90b78fe5307bb195d96db6280b7c972f Mon Sep 17 00:00:00 2001 From: thiendekaco Date: Wed, 15 Jan 2025 15:46:43 +0700 Subject: [PATCH 2/2] [issue-278] Mythical_Telegram_App - Error not showing card with Power > 110 when filtering #1 --- .../src/Popup/Home/Cards/ToolFiters/ToolFiltersModal.tsx | 6 +++--- .../src/constants/myth/optionFilterCard.ts | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/extension-koni-ui/src/Popup/Home/Cards/ToolFiters/ToolFiltersModal.tsx b/packages/extension-koni-ui/src/Popup/Home/Cards/ToolFiters/ToolFiltersModal.tsx index 277c6414f6..ccb3b4c301 100644 --- a/packages/extension-koni-ui/src/Popup/Home/Cards/ToolFiters/ToolFiltersModal.tsx +++ b/packages/extension-koni-ui/src/Popup/Home/Cards/ToolFiters/ToolFiltersModal.tsx @@ -3,7 +3,7 @@ import { MythButton } from '@subwallet/extension-koni-ui/components/Mythical'; import { NFLRivalCard } from '@subwallet/extension-koni-ui/connector/booka/types'; -import { MaxLevelIdx, MaxPowerIdx } from '@subwallet/extension-koni-ui/constants'; +import { MaxLevelOptionId, MaxPowerOptionId } from '@subwallet/extension-koni-ui/constants'; import { ConditionProcessState } from '@subwallet/extension-koni-ui/Popup/Home/Cards'; import { FilterItems, FilterOption } from '@subwallet/extension-koni-ui/Popup/Home/Cards/ToolFiters/index'; import { ThemeProps } from '@subwallet/extension-koni-ui/types'; @@ -100,13 +100,13 @@ const Component = ({ className, filterItems, handleCancel, handleReset, onConfir let isCardLevelPassed = tmpItemsSelected[FilterOption.LEVEL_OPTION].length === 0; if (!isCardPowerPassed) { - const idx = Math.min(Math.floor((card.power - 50 >= 0 ? card.power - 50 : 0) / 10), MaxPowerIdx); + const idx = Math.min(Math.floor((card.power - 50 >= 0 ? card.power - 50 : 0) / 10), MaxPowerOptionId); isCardPowerPassed = tmpItemsSelected[FilterOption.POWER_OPTION].includes(idx.toString()); } if (!isCardLevelPassed) { - const idx = Math.min(Math.floor(card.level / 5), MaxLevelIdx); + const idx = Math.min(Math.floor(card.level / 5), MaxLevelOptionId); isCardLevelPassed = tmpItemsSelected[FilterOption.LEVEL_OPTION].includes(idx.toString()); } diff --git a/packages/extension-koni-ui/src/constants/myth/optionFilterCard.ts b/packages/extension-koni-ui/src/constants/myth/optionFilterCard.ts index 370fbc0415..cb655ea69a 100644 --- a/packages/extension-koni-ui/src/constants/myth/optionFilterCard.ts +++ b/packages/extension-koni-ui/src/constants/myth/optionFilterCard.ts @@ -98,7 +98,12 @@ export const RarityOptions = [ { id: 'mythical', label: 'Mythical' } ]; -export const MaxPowerIdx = 5; +/* +Apply the formula to determine the ID of the list of options to determine the selected option. +Since the previous options were built based on value ranges that have the same cycle, to cover the range of remaining attribute values, +it is necessary to use MaxId to round up to the largest ID in case the remaining attribute values do not follow the cycle." + */ +export const MaxPowerOptionId = 5; export const PowerOptions = [ { id: '0', label: '<60' }, { id: '1', label: '60-69' }, @@ -108,7 +113,7 @@ export const PowerOptions = [ { id: '5', label: '100+' } ]; -export const MaxLevelIdx = 4; +export const MaxLevelOptionId = 4; export const LevelOptions = [ { id: '0', label: '≥1' }, { id: '1', label: '≥5' },