Skip to content

Commit 27ee543

Browse files
committed
fix: improve token info fetching logic in tokenMarketInfoIfAvailable
1 parent 62e2e71 commit 27ee543

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

lib/app/features/tokenized_communities/providers/token_market_info_provider.r.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,21 @@ AsyncValue<CommunityToken?> tokenMarketInfoIfAvailable(
7979
);
8080
final hasToken = hasTokenAsync.valueOrNull ?? false;
8181

82-
if (!hasToken) {
82+
// Always try to fetch token info from the analytics service
83+
// even if first-buy definition is not cached yet
84+
final tokenInfo = ref.watch(tokenMarketInfoProvider(eventReference.toString()));
85+
86+
// If we have token data from analytics, return it (even if hasToken is false due to cache miss)
87+
if (tokenInfo.hasValue && tokenInfo.value != null) {
88+
return tokenInfo;
89+
}
90+
91+
// Only return null if hasToken is definitely false AND we have no token data
92+
if (!hasToken && (!tokenInfo.hasValue || tokenInfo.value == null)) {
8393
return const AsyncData(null);
8494
}
8595

86-
return ref.watch(tokenMarketInfoProvider(eventReference.toString()));
96+
return tokenInfo;
8797
}
8898

8999
@riverpod

0 commit comments

Comments
 (0)