Skip to content

Commit 8c4968a

Browse files
Merge branch 'main' into feat/frontend-load-user-profile-signups-closed
2 parents 3792fc1 + 008a73a commit 8c4968a

5 files changed

Lines changed: 50 additions & 33 deletions

File tree

src/frontend/src/lib/components/transactions/AllTransactions.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import { enabledFungibleNetworkTokens } from '$lib/derived/network-tokens.derived';
1414
import { isPrivacyMode } from '$lib/derived/settings.derived';
1515
import {
16+
hiddenMicroTransactionsBannerVisible,
1617
userDismissedNotifications,
1718
userProfileVersion
1819
} from '$lib/derived/user-profile.derived';
@@ -120,7 +121,8 @@
120121
let hasBanners = $derived(
121122
undismissedNoCanister.length > 0 ||
122123
tokensWithUnavailableCanister.length > 0 ||
123-
!btcBannerDismissed
124+
!btcBannerDismissed ||
125+
$hiddenMicroTransactionsBannerVisible
124126
);
125127
</script>
126128

@@ -159,10 +161,10 @@
159161
{$i18n.activity.info.btc_transactions}
160162
</MessageBox>
161163
{/if}
164+
165+
<HiddenMicroTransactionsInfoBox />
162166
</div>
163167
{/if}
164168

165-
<HiddenMicroTransactionsInfoBox />
166-
167169
<AllTransactionsList />
168170
</div>

src/frontend/src/lib/components/transactions/HiddenMicroTransactionsInfoBox.svelte

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,34 @@
55
import { NOTIFICATION_VERSIONS } from '$lib/constants/notification.constants';
66
import { authIdentity } from '$lib/derived/auth.derived';
77
import {
8-
hideMicroTransactions,
9-
userDismissedNotifications,
8+
hiddenMicroTransactionsBannerVisible,
109
userProfileVersion
1110
} from '$lib/derived/user-profile.derived';
1211
import { dismissNotifications } from '$lib/services/notification.services';
1312
import { i18n } from '$lib/stores/i18n.store';
1413
import { hiddenMicroTransactionsResetStore } from '$lib/stores/settings.store';
15-
import { isSimpleNotificationDismissed } from '$lib/utils/notification.utils';
1614
17-
let temporaryDismissedNotifications = $state<DismissedNotification[]>([]);
15+
// Optimistic local dismissal: the backend dismiss call is an update call that takes
16+
// some time to complete. Keep an instant local override so the box hides immediately
17+
// when the user clicks dismiss; it is cleared once the global signal turns off.
18+
let locallyDismissed = $state(false);
1819
19-
let allDismissedNotifications = $derived([
20-
...$userDismissedNotifications,
21-
...temporaryDismissedNotifications
22-
]);
20+
$effect(() => {
21+
if (!$hiddenMicroTransactionsBannerVisible) {
22+
locallyDismissed = false;
23+
}
24+
});
2325
24-
let backendDismissed = $derived(
25-
isSimpleNotificationDismissed({
26-
kind: 'HiddenMicroTransactions',
27-
dismissedNotifications: allDismissedNotifications
28-
})
29-
);
26+
let visible = $derived($hiddenMicroTransactionsBannerVisible && !locallyDismissed);
3027
31-
// When the user toggles the "hide micro transactions" feature, we re-show the
32-
// info box even if the backend still has the notification stored as dismissed. The override
33-
// is cleared as soon as the user dismisses the info box again.
34-
let dismissed = $derived(backendDismissed && !$hiddenMicroTransactionsResetStore.enabled);
28+
const dismiss = () => {
29+
locallyDismissed = true;
3530
36-
let visible = $derived($hideMicroTransactions && !dismissed);
31+
hiddenMicroTransactionsResetStore.set({
32+
key: 'hidden-micro-transactions-reset',
33+
value: { enabled: false }
34+
});
3735
38-
const dismiss = () => {
3936
const notifications: DismissedNotification[] = [
4037
{
4138
Simple: {
@@ -45,13 +42,6 @@
4542
}
4643
];
4744
48-
temporaryDismissedNotifications = [...temporaryDismissedNotifications, ...notifications];
49-
50-
hiddenMicroTransactionsResetStore.set({
51-
key: 'hidden-micro-transactions-reset',
52-
value: { enabled: false }
53-
});
54-
5545
dismissNotifications({
5646
notifications,
5747
identity: $authIdentity,

src/frontend/src/lib/derived/user-profile.derived.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import type {
99
TransactionSettings,
1010
UserProfile
1111
} from '$declarations/backend/backend.did';
12+
import { hiddenMicroTransactionsResetStore } from '$lib/stores/settings.store';
1213
import { userProfileStore } from '$lib/stores/user-profile.store';
14+
import { isSimpleNotificationDismissed } from '$lib/utils/notification.utils';
1315
import { fromNullishNullable, nonNullish } from '@dfinity/utils';
1416
import { derived, type Readable } from 'svelte/store';
1517

@@ -72,3 +74,26 @@ export const hideMicroTransactions: Readable<boolean> = derived(
7274
[userTransactionFilterSettings],
7375
([$userTransactionFilterSettings]) => $userTransactionFilterSettings.hide_micro_transactions
7476
);
77+
78+
// Whether the "hidden micro transactions" info banner should be visible. Derived from
79+
// global state only (no component-local optimistic dismissal), so it can be consumed both
80+
// by `HiddenMicroTransactionsInfoBox` (which renders it) and by parents that need to know
81+
// about its visibility (e.g. to include it in a "has banners" derivation).
82+
export const hiddenMicroTransactionsBannerVisible: Readable<boolean> = derived(
83+
[hideMicroTransactions, userDismissedNotifications, hiddenMicroTransactionsResetStore],
84+
([$hideMicroTransactions, $userDismissedNotifications, $hiddenMicroTransactionsResetStore]) => {
85+
if (!$hideMicroTransactions) {
86+
return false;
87+
}
88+
89+
const backendDismissed = isSimpleNotificationDismissed({
90+
kind: 'HiddenMicroTransactions',
91+
dismissedNotifications: $userDismissedNotifications
92+
});
93+
94+
// When the user toggles the "hide micro transactions" feature, we re-show the info
95+
// box even if the backend still has the notification stored as dismissed. The override
96+
// is cleared as soon as the user dismisses the info box again.
97+
return !(backendDismissed && !$hiddenMicroTransactionsResetStore.enabled);
98+
}
99+
);

src/frontend/src/lib/utils/exchange.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const usdValue = ({
3131
) * exchangeRate
3232
: Number(ZERO);
3333

34-
const ICPSWAP_MIN_TVL_USD = 10;
34+
const ICPSWAP_MIN_TVL_USD = 500;
3535

3636
export const formatIcpSwapToCoingeckoPrices = (
3737
tokens: IcpSwapToken[]

src/frontend/src/tests/lib/utils/exchange.utils.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('exchange.utils', () => {
7272
it('skips token where tvlUSD is exactly at the threshold', () => {
7373
const mock = createMockIcpSwapToken({
7474
price: '1.230000000000000000',
75-
tvlUSD: '10.000000000000000000'
75+
tvlUSD: '500.000000000000000000'
7676
});
7777
const result = formatIcpSwapToCoingeckoPrices([mock]);
7878

@@ -83,7 +83,7 @@ describe('exchange.utils', () => {
8383
const mock = createMockIcpSwapToken({
8484
tokenLedgerId: MOCK_CANISTER_ID_1,
8585
price: '1.230000000000000000',
86-
tvlUSD: '10.010000000000000000'
86+
tvlUSD: '500.010000000000000000'
8787
});
8888
const result = formatIcpSwapToCoingeckoPrices([mock]);
8989

0 commit comments

Comments
 (0)