From e5b2b487fdedbbb8d11b6f020a0e7e09582d1163 Mon Sep 17 00:00:00 2001 From: Daria <2395326+piggydoughnut@users.noreply.github.com> Date: Thu, 6 Feb 2025 00:36:10 +1300 Subject: [PATCH] fix: showing what core the chain is renewed on (#11256) * fix: showing what core the chain is renewed on * removed the code that is part of another pr * better wording --- .../react-hooks/src/useCoretimeInformation.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/react-hooks/src/useCoretimeInformation.ts b/packages/react-hooks/src/useCoretimeInformation.ts index 4874e3e9255a..9b1c5da84be8 100644 --- a/packages/react-hooks/src/useCoretimeInformation.ts +++ b/packages/react-hooks/src/useCoretimeInformation.ts @@ -132,15 +132,21 @@ function useCoretimeInformationImpl (api: ApiPromise, ready: boolean): CoretimeI const workloads = workloadData?.filter((one) => one.info.task === taskId); const workTaskInfo = workloads.map((workload) => { - const workplan = workplans?.filter((workplan) => workplan.core === workload?.core && workplan.info.task.toString() === taskId); + // parachain can be renewed on a different core + const workplan = workplans?.filter((workplan) => workplan.info.task.toString() === taskId); const type = getOccupancyType(lease, reservation, workload?.info.isPool ?? false); - const chainRenewedCore = type === CoreTimeTypes['Bulk Coretime'] && workplan?.find((a) => a.core === workload?.core); - const renewal = potentialRenewalsCurrentRegion?.find((renewal) => renewal.task.toString() === taskId); - const renewalStatus = chainRenewedCore ? ChainRenewalStatus.Renewed : renewal ? ChainRenewalStatus.Eligible : ChainRenewalStatus.None; + const potentialRenewal = potentialRenewalsCurrentRegion?.find((renewal) => renewal.task.toString() === taskId); + + let renewalStatus = potentialRenewal ? ChainRenewalStatus.Eligible : ChainRenewalStatus.None; + const chainRenewedCore = type === CoreTimeTypes['Bulk Coretime'] && !!workplan?.length; + + if (chainRenewedCore) { + renewalStatus = `Next cycle on core ${workplan[0].core}`; + } return { chainRenewedCore, - renewal, + renewal: potentialRenewal, renewalStatus, type, workload,