From a3d8856aa3b0b121cc847883aa78b83db57961ca Mon Sep 17 00:00:00 2001 From: Mark Nardi Date: Tue, 27 Feb 2024 15:23:17 +0100 Subject: [PATCH] rename + cleanup --- .../row-sections/ActivityAssetSection.svelte | 4 +- .../row-sections/getActivityActionColor.ts | 38 ----------------- .../row-sections/getActivityActionPill.ts | 42 ------------------- ...Color.ts => getActivityActionTextColor.ts} | 2 +- .../src/lib/core/activity/utils/index.ts | 2 +- 5 files changed, 4 insertions(+), 84 deletions(-) delete mode 100644 packages/desktop/views/dashboard/wallet/tab-section/activity/components/row-sections/getActivityActionColor.ts delete mode 100644 packages/desktop/views/dashboard/wallet/tab-section/activity/components/row-sections/getActivityActionPill.ts rename packages/shared/src/lib/core/activity/utils/{getActivityActionColor.ts => getActivityActionTextColor.ts} (94%) diff --git a/packages/desktop/views/dashboard/wallet/tab-section/activity/components/row-sections/ActivityAssetSection.svelte b/packages/desktop/views/dashboard/wallet/tab-section/activity/components/row-sections/ActivityAssetSection.svelte index 02cc8a2e7d..ff05f4a23a 100644 --- a/packages/desktop/views/dashboard/wallet/tab-section/activity/components/row-sections/ActivityAssetSection.svelte +++ b/packages/desktop/views/dashboard/wallet/tab-section/activity/components/row-sections/ActivityAssetSection.svelte @@ -10,7 +10,7 @@ } from '@ui' import { ActivityType, - getActivityActionColor, + getActivityActionTextColor, getActivityActionPill, getActivityTileAction, getActivityTileAsset, @@ -40,7 +40,7 @@ ? getNftByIdFromAllAccountNfts($selectedAccountIndex, activity.nftId) : undefined) - $: color = getActivityActionColor(activity) + $: color = getActivityActionTextColor(activity) $: pill = getActivityActionPill(activity, $time) diff --git a/packages/desktop/views/dashboard/wallet/tab-section/activity/components/row-sections/getActivityActionColor.ts b/packages/desktop/views/dashboard/wallet/tab-section/activity/components/row-sections/getActivityActionColor.ts deleted file mode 100644 index e976b14bc7..0000000000 --- a/packages/desktop/views/dashboard/wallet/tab-section/activity/components/row-sections/getActivityActionColor.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Activity, ActivityAction, ActivityDirection, ActivityType } from '@core/activity' - -export function getActivityActionColor(activity: Activity, darkMode: boolean): string { - const { type, direction, action } = activity - - if (type === ActivityType.Basic && activity.isShimmerClaiming) { - return 'info' - } - if (type === ActivityType.Governance) { - return darkMode ? 'neutral-1' : 'neutral-7' - } else if (type === ActivityType.Consolidation) { - return darkMode ? 'neutral-1' : 'neutral-7' - } else if (type === ActivityType.SmartContract) { - return 'brand' - } else if (action === ActivityAction.Mint) { - return 'success' - } else if (action === ActivityAction.Burn) { - return 'danger' - } else if (action === ActivityAction.InitialBalance) { - return darkMode ? 'neutral-1' : 'neutral-7' - } else if (action === ActivityAction.Send || action === ActivityAction.BalanceChange) { - const isReceived = [ - ActivityDirection.Incoming, - ActivityDirection.SelfTransaction, - ActivityDirection.Genesis, - ].includes(direction) - - if (direction === ActivityDirection.Outgoing) { - return 'brand' - } else if (isReceived) { - return 'info' - } else { - return darkMode ? 'neutral-1' : 'neutral-7' - } - } else { - return darkMode ? 'neutral-1' : 'neutral-7' - } -} diff --git a/packages/desktop/views/dashboard/wallet/tab-section/activity/components/row-sections/getActivityActionPill.ts b/packages/desktop/views/dashboard/wallet/tab-section/activity/components/row-sections/getActivityActionPill.ts deleted file mode 100644 index 30b635eecb..0000000000 --- a/packages/desktop/views/dashboard/wallet/tab-section/activity/components/row-sections/getActivityActionPill.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Activity, ActivityAsyncStatus, ActivityDirection } from '@core/activity' -import { getTimeDifference } from '@core/utils/time' - -export function getActivityActionPill( - activity: Activity, - currentDate: Date -): { type: 'timelock' | 'unclaimed' | 'expired'; timeDiff?: string } | undefined { - if (!activity?.asyncData?.asyncStatus) { - return undefined - } - - const { asyncStatus, expirationDate, timelockDate } = activity.asyncData - - switch (asyncStatus) { - case ActivityAsyncStatus.Claimed: { - return undefined - } - case ActivityAsyncStatus.Timelocked: { - if (activity.direction === ActivityDirection.Outgoing) { - if (expirationDate) { - const timeDiff = getTimeDifference(expirationDate, currentDate) - return { type: 'unclaimed', timeDiff } - } else { - return undefined - } - } else { - const timeDiff = getTimeDifference(timelockDate, currentDate) - return { type: 'timelock', timeDiff } - } - } - case ActivityAsyncStatus.Unclaimed: { - const timeDiff = expirationDate ? getTimeDifference(expirationDate, currentDate) : undefined - return { type: 'unclaimed', timeDiff } - } - case ActivityAsyncStatus.Expired: { - return { type: 'expired' } - } - default: { - return undefined - } - } -} diff --git a/packages/shared/src/lib/core/activity/utils/getActivityActionColor.ts b/packages/shared/src/lib/core/activity/utils/getActivityActionTextColor.ts similarity index 94% rename from packages/shared/src/lib/core/activity/utils/getActivityActionColor.ts rename to packages/shared/src/lib/core/activity/utils/getActivityActionTextColor.ts index bcb3e0d257..f9861983a1 100644 --- a/packages/shared/src/lib/core/activity/utils/getActivityActionColor.ts +++ b/packages/shared/src/lib/core/activity/utils/getActivityActionTextColor.ts @@ -1,7 +1,7 @@ import { TextColor } from '@bloomwalletio/ui' import { Activity, ActivityAction, ActivityDirection, ActivityType, GovernanceAction } from '@core/activity' -export function getActivityActionColor(activity: Activity): TextColor { +export function getActivityActionTextColor(activity: Activity): TextColor { const { type, direction, action } = activity if (type === ActivityType.Basic && activity.isShimmerClaiming) { diff --git a/packages/shared/src/lib/core/activity/utils/index.ts b/packages/shared/src/lib/core/activity/utils/index.ts index 7d8ec3f0d4..f0c50eb7c9 100644 --- a/packages/shared/src/lib/core/activity/utils/index.ts +++ b/packages/shared/src/lib/core/activity/utils/index.ts @@ -14,7 +14,7 @@ export * from './generateSingleFoundryActivity' export * from './generateSingleGovernanceActivity' export * from './generateSingleNftActivity' export * from './getActivityDetailsTitle' -export * from './getActivityActionColor' +export * from './getActivityActionTextColor' export * from './getActivityActionPill' export * from './getActivityTileAction' export * from './getActivityTileAsset'