Skip to content

fix: pass right type param, add session ttl handling#3653

Open
ice-evander wants to merge 1 commit into
masterfrom
bugfix/tc-filter-creator-tokens-by-type
Open

fix: pass right type param, add session ttl handling#3653
ice-evander wants to merge 1 commit into
masterfrom
bugfix/tc-filter-creator-tokens-by-type

Conversation

@ice-evander

Copy link
Copy Markdown
Contributor

Description

pass right type param, add session ttl handling, fix stale sessionId initialization

Task ID

related to ION-5729

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring
  • Documentation
  • Chore

@ice-evander ice-evander requested review from a team, ice-hades and ice-orion as code owners March 12, 2026 22:10
@ice-morpheus ice-morpheus enabled auto-merge (squash) March 12, 2026 22:10
@ice-evander ice-evander force-pushed the bugfix/tc-filter-creator-tokens-by-type branch from c928aa0 to c7dba46 Compare March 12, 2026 22:11
@ice-morpheus ice-morpheus force-pushed the bugfix/tc-filter-creator-tokens-by-type branch from c7dba46 to 26f1597 Compare March 13, 2026 07:41
@ice-morpheus ice-morpheus force-pushed the bugfix/tc-filter-creator-tokens-by-type branch 11 times, most recently from 71f778b to e735c08 Compare March 16, 2026 09:38
@ice-orion ice-orion requested a review from Copilot March 16, 2026 09:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 type values in latest tokens REST + SSE requests.
  • Update TokenTypeFilter.requestType mapping to new backend values (onlineplus_creator, onlineplus_content, xcom) and document backend-driven filtering.
  • Add a timer-driven viewing-session refresh mechanism to CategoryTokensNotifier to 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.

Comment on lines +40 to +46
/// 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), () {
Comment on lines +21 to +22
/// [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);

@ice-orion ice-orion Mar 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we refresh the token exactly 30 seconds before it expires?

@ice-morpheus ice-morpheus force-pushed the bugfix/tc-filter-creator-tokens-by-type branch from e735c08 to eb37d4b Compare March 16, 2026 10:03
_type = type;

ref.onDispose(() async {
_disposed = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@ice-morpheus ice-morpheus force-pushed the bugfix/tc-filter-creator-tokens-by-type branch 4 times, most recently from 7dd5472 to d5c619d Compare March 16, 2026 12:50
@ice-morpheus ice-morpheus force-pushed the bugfix/tc-filter-creator-tokens-by-type branch 28 times, most recently from 3478443 to 40dfa5a Compare March 19, 2026 11:28
@ice-morpheus ice-morpheus force-pushed the bugfix/tc-filter-creator-tokens-by-type branch from 40dfa5a to 5904dcf Compare March 19, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants