From 17f18eb7f0ecbf2311222db27e682386d4d12296 Mon Sep 17 00:00:00 2001 From: Damir Shamanaev Date: Wed, 1 Feb 2023 23:34:31 +0300 Subject: [PATCH] [frenemies] Adds 'about a min' (#8000) --- .../src/components/your-score/Refresh.tsx | 2 +- dapps/frenemies/src/utils/format.ts | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/dapps/frenemies/src/components/your-score/Refresh.tsx b/dapps/frenemies/src/components/your-score/Refresh.tsx index 27b2d373bf5a1..f3c65030d9f97 100644 --- a/dapps/frenemies/src/components/your-score/Refresh.tsx +++ b/dapps/frenemies/src/components/your-score/Refresh.tsx @@ -48,7 +48,7 @@ export function Refresh({ scorecard, round, leaderboardID }: Props) { function: "update", gasPayment: normalizeSuiAddress(gas.reference.objectId), typeArguments: [], - gasBudget: 1000000, + gasBudget: Number(GAS_BUDGET), arguments: [ normalizeSuiAddress(scorecard.reference.objectId), SUI_SYSTEM_ID, diff --git a/dapps/frenemies/src/utils/format.ts b/dapps/frenemies/src/utils/format.ts index dbbe3b2fdc91c..3841581364d23 100644 --- a/dapps/frenemies/src/utils/format.ts +++ b/dapps/frenemies/src/utils/format.ts @@ -33,14 +33,15 @@ export function formatBalance( /** Print time in the format `hh:mm:ss` */ export function formatTimeRemaining(timer: number): string { - return `${new Date(timer) - .getUTCHours() - .toString() - .padStart(2, "0")}:${new Date(timer) - .getUTCMinutes() - .toString() - .padStart(2, "0")}:${new Date(timer) - .getUTCSeconds() - .toString() - .padStart(2, "0")}`; + const date = new Date(timer); + const hh = date.getUTCHours().toString().padStart(2, '0'); + const mm = date.getUTCMinutes().toString().padStart(2, '0'); + const ss = date.getUTCSeconds().toString().padStart(2, '0'); + + // When it's less than a minute, we show a text + if (hh == '00' && mm == '00') { + return 'About a min'; + } + + return `${hh}:${mm}:${ss}`; }