fix: pass right type param, add session ttl handling#3653
Conversation
c928aa0 to
c7dba46
Compare
c7dba46 to
26f1597
Compare
71f778b to
e735c08
Compare
There was a problem hiding this comment.
Pull request overview
Updates creator/community token type filtering to align with the analytics API’s expected type query parameter values, and improves reliability of category token viewing sessions by proactively refreshing before expiry.
Changes:
- Avoid sending empty
typevalues in latest tokens REST + SSE requests. - Update
TokenTypeFilter.requestTypemapping to new backend values (onlineplus_creator,onlineplus_content,xcom) and document backend-driven filtering. - Add a timer-driven viewing-session refresh mechanism to
CategoryTokensNotifierto recreate sessions before TTL expiry.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/ion_token_analytics/lib/src/community_tokens/latest_tokens/latest_tokens_repository_impl.dart | Prevents empty type query param from being sent to latest tokens endpoints. |
| lib/app/features/user/pages/creator_tokens/views/creator_tokens_page/components/tabs/creator_tokens_tab_content.dart | Adds docs clarifying that token type filtering is backend-driven. |
| lib/app/features/user/pages/creator_tokens/models/token_type_filter.dart | Updates the backend type query param values used by creator/content/x filters. |
| lib/app/features/tokenized_communities/providers/category_tokens_provider.r.dart | Adds TTL-based timer to refresh viewing sessions and resubscribes to realtime updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| /// TTL from API: typically seconds (e.g. 300 = 5 min); | ||
| void _scheduleSessionRecreate(ViewingSession session) { | ||
| _sessionExpiryTimer?.cancel(); | ||
| _sessionExpiryTimer = null; | ||
| final ttlSec = session.ttl >= 1000 ? session.ttl ~/ 1000 : session.ttl; | ||
| final refreshInSec = (ttlSec - _sessionRefreshBeforeExpirySec).clamp(1, ttlSec); | ||
| _sessionExpiryTimer = Timer(Duration(seconds: refreshInSec), () { |
| /// [requestType] is sent to the analytics API for category (Trending/Top) and | ||
| /// latest endpoints; the UI shows [state.activeItems] with no client-side filtering. |
| _sessionExpiryTimer?.cancel(); | ||
| _sessionExpiryTimer = null; | ||
| final ttlSec = session.ttl >= 1000 ? session.ttl ~/ 1000 : session.ttl; | ||
| final refreshInSec = (ttlSec - _sessionRefreshBeforeExpirySec).clamp(1, ttlSec); |
There was a problem hiding this comment.
Is there a reason we refresh the token exactly 30 seconds before it expires?
e735c08 to
eb37d4b
Compare
| _type = type; | ||
|
|
||
| ref.onDispose(() async { | ||
| _disposed = true; |
There was a problem hiding this comment.
Don't we have an issue with this _disposed - u set it to true but u never reset it.
ref.onDispose is called, for example, when a dependency is changed and the same instance is used, so the provider will remain in _disposed->true state in this case.
And why do we need this flag in the first place? The only place where it is used is in the Timer callback and u cancel all the timers in the same place u set this flag, so isn't it redundant?
7dd5472 to
d5c619d
Compare
3478443 to
40dfa5a
Compare
40dfa5a to
5904dcf
Compare
Description
pass right type param, add session ttl handling, fix stale sessionId initialization
Task ID
related to ION-5729
Type of Change