Skip to content

Commit 144a0eb

Browse files
committed
code review
1 parent e4229ad commit 144a0eb

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

packages/core-mobile/app/new/features/notifications/screens/NotificationsScreen.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
isPriceAlertNotification,
3636
isBalanceChangeNotification
3737
} from '../types'
38-
import { isSwapCompletedOrFailed } from '../utils'
38+
import { isSwapTerminal } from '../utils'
3939
import { FusionTransferItem } from '../components/FusionTransferItem'
4040

4141
const TITLE = 'Notifications'
@@ -176,7 +176,7 @@ export const NotificationsScreen = (): JSX.Element => {
176176
combinedItems.filter(
177177
item =>
178178
item.kind === 'notification' ||
179-
(item.kind === 'swap' && isSwapCompletedOrFailed(item.item.transfer))
179+
(item.kind === 'swap' && isSwapTerminal(item.item.transfer))
180180
),
181181
[combinedItems]
182182
)
@@ -292,16 +292,16 @@ export const NotificationsScreen = (): JSX.Element => {
292292

293293
if (combined.kind === 'swap') {
294294
const transfer = combined.item
295-
const isCompletedOrFailed = isSwapCompletedOrFailed(transfer.transfer)
295+
const isTerminal = isSwapTerminal(transfer.transfer)
296296
return (
297297
<SwipeableRow
298298
animateOut={
299-
isCompletedOrFailed && isClearingAll && index < MAX_ANIMATED_ITEMS
299+
isTerminal && isClearingAll && index < MAX_ANIMATED_ITEMS
300300
}
301301
animateDelay={index * SWIPE_DELAY}
302302
onSwipeComplete={() => removeTransfer(transfer.transfer.id)}
303303
onPress={() => handleSwapActivityPress(transfer)}
304-
enabled={!isClearingAll && isCompletedOrFailed}>
304+
enabled={!isClearingAll && isTerminal}>
305305
<FusionTransferItem
306306
item={transfer}
307307
showSeparator={!isLast}

packages/core-mobile/app/new/features/notifications/screens/SwapActivityDetailScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const SwapActivityDetailScreen = (): JSX.Element => {
5353
}
5454
return (
5555
<Button size="large" type="primary" onPress={handleDismiss}>
56-
{'Hide'}
56+
Hide
5757
</Button>
5858
)
5959
}

packages/core-mobile/app/new/features/notifications/utils.test.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Transfer } from '@avalabs/fusion-sdk'
22
import { AppNotification, NotificationCategory, NotificationTab } from './types'
33
import {
44
filterByTab,
5-
isSwapCompletedOrFailed,
5+
isSwapTerminal,
66
mapTransferToSourceChainStatus,
77
mapTransferToSwapStatus,
88
mapTransferToTargetChainStatus,
@@ -148,33 +148,31 @@ describe('mapTransferToSwapStatus', () => {
148148
)
149149
})
150150

151-
// ─── isSwapCompletedOrFailed ────────────────────────────────────────────────────────
151+
// ─── isSwapTerminal ────────────────────────────────────────────────────────
152152

153-
describe('isSwapCompletedOrFailed', () => {
153+
describe('isSwapTerminal', () => {
154154
it('returns true when the swap is completed', () => {
155-
expect(isSwapCompletedOrFailed(makeTransfer('completed'))).toBe(true)
155+
expect(isSwapTerminal(makeTransfer('completed'))).toBe(true)
156156
})
157157

158158
it('returns true when the swap has failed', () => {
159-
expect(isSwapCompletedOrFailed(makeTransfer('failed'))).toBe(true)
159+
expect(isSwapTerminal(makeTransfer('failed'))).toBe(true)
160160
})
161161

162162
it('returns true when the swap was refunded (partial failure)', () => {
163-
expect(isSwapCompletedOrFailed(makeTransfer('refunded'))).toBe(true)
163+
expect(isSwapTerminal(makeTransfer('refunded'))).toBe(true)
164164
})
165165

166166
it('returns false when the swap is in progress (source-pending)', () => {
167-
expect(isSwapCompletedOrFailed(makeTransfer('source-pending'))).toBe(false)
167+
expect(isSwapTerminal(makeTransfer('source-pending'))).toBe(false)
168168
})
169169

170170
it('returns false when the swap is in progress (target-pending)', () => {
171-
expect(isSwapCompletedOrFailed(makeTransfer('target-pending'))).toBe(false)
171+
expect(isSwapTerminal(makeTransfer('target-pending'))).toBe(false)
172172
})
173173

174174
it('returns false when the swap is in progress (source-completed)', () => {
175-
expect(isSwapCompletedOrFailed(makeTransfer('source-completed'))).toBe(
176-
false
177-
)
175+
expect(isSwapTerminal(makeTransfer('source-completed'))).toBe(false)
178176
})
179177
})
180178

packages/core-mobile/app/new/features/notifications/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
* the user can track them; only terminal states (completed / failed / refunded)
1616
* are eligible for removal.
1717
*/
18-
export function isSwapCompletedOrFailed(transfer: Transfer): boolean {
18+
export function isSwapTerminal(transfer: Transfer): boolean {
1919
const status = mapTransferToSwapStatus(transfer)
2020
return status === 'completed' || status === 'failed' || status === 'refunded'
2121
}

0 commit comments

Comments
 (0)